nanomsg-0.8-beta/0000775000175000017500000000000012623652617014652 5ustar00travistravis00000000000000nanomsg-0.8-beta/doc/0000775000175000017500000000000012623652617015417 5ustar00travistravis00000000000000nanomsg-0.8-beta/doc/asciidoc.conf0000664000175000017500000000231112623652600020031 0ustar00travistravis00000000000000[paradef-default] literal-style=template="literalparagraph" [macros] (?su)[\\]?(?Plinknanomsg):(?P\S*?)\[(?P.*?)\]= ifdef::backend-docbook[] [linknanomsg-inlinemacro] {0%{target}} {0#} {0#{target}{0}} {0#} endif::backend-docbook[] ifdef::backend-xhtml11[] [linknanomsg-inlinemacro] {target}{0?({0})} endif::backend-xhtml11[] ifdef::doctype-manpage[] ifdef::backend-docbook[] [header] template::[header-declarations] {mantitle} {manvolnum} nanomsg {version} nanomsg manual {manname} {manpurpose} endif::backend-docbook[] endif::doctype-manpage[] ifdef::backend-xhtml11[] [footer] {disable-javascript%

} endif::backend-xhtml11[] nanomsg-0.8-beta/doc/htmldoc.css0000664000175000017500000000035612623652600017557 0ustar00travistravis00000000000000p {font-family:sans-serif;} h1,h2,h3,h4,h5,h6 {color:#808080;} a {color:#000000;} a:visited {color:#000000;} dt {color:#000000; font-style: italic;} tt {color: #000000;} em {color: #000000;} strong {color: #000000; font-weight: bold;} nanomsg-0.8-beta/doc/nanocat.txt0000664000175000017500000001222612623652600017576 0ustar00travistravis00000000000000nanocat(1) ========== NAME ---- nanocat - a command-line interface to nanomsg SYNOPSIS -------- nanocat --req {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-i SEC] [-AQ] nanocat --rep {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-AQ] nanocat --push {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-i SEC] nanocat --pull {--connect ADDR|--bind ADDR} [-AQ] nanocat --pub {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-i SEC] nanocat --sub {--connect ADDR|--bind ADDR} [--subscribe PREFIX ...] [-AQ] nanocat --surveyor {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-i SEC] [-AQ] nanocat --respondent {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-AQ] nanocat --bus {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-i SEC] [-AQ] nanocat --pair {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-i SEC] [-AQ] In the case symlinks are installed: nn_req {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-i SEC] [-AQ] nn_rep {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-AQ] nn_push {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-i SEC] nn_pull {--connect ADDR|--bind ADDR} [-AQ] nn_pub {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-i SEC] nn_sub {--connect ADDR|--bind ADDR} [--subscribe PREFIX ...] [-AQ] nn_surveyor {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-i SEC] [-AQ] nn_respondent {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-AQ] nn_bus {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-i SEC] [-AQ] nn_pair {--connect ADDR|--bind ADDR} {--data DATA|--file PATH} [-i SEC] [-AQ] DESCRIPTION ----------- The nanocat is a command-line tool to send and receive data via nanomsg sockets. It can be used for debugging purposes, sending files through the network, health checking the system or whatever else you can think of. OPTIONS ------- Generic: *--verbose,-v*:: Increase verbosity of the nanocat *--silent,-q*:: Decrease verbosity of the nanocat *--help,-h*:: This help text Socket Types: *--push*:: Use NN_PUSH socket type *--pull*:: Use NN_PULL socket type *--pub*:: Use NN_PUB socket type *--sub*:: Use NN_SUB socket type *--req*:: Use NN_REQ socket type *--rep*:: Use NN_REP socket type *--surveyor*:: Use NN_SURVEYOR socket type *--respondent*:: Use NN_RESPONDENT socket type *--bus*:: Use NN_BUS socket type *--pair*:: Use NN_PAIR socket type Socket Options: *--bind* 'ADDR':: Bind socket to the address ADDR *--connect* 'ADDR':: Connect socket to the address ADDR *--bind-ipc,-X* 'PATH':: Bind socket to the ipc address "ipc://PATH". *--connect-ipc,-x* 'PATH':: Connect socket to the ipc address "ipc://PATH". *--bind-local,-L* 'PORT':: Bind socket to the tcp address "tcp://127.0.0.1:PORT". *--connect-local,-l* 'PORT':: Connect socket to the tcp address "tcp://127.0.0.1:PORT". *--recv-timeout* 'SEC':: Set timeout for receiving a message *--send-timeout* 'SEC':: Set timeout for sending a message SUB Socket Options: *--subscribe* 'PREFIX':: Subscribe to the prefix PREFIX. Note: socket will be subscribed to everything (empty prefix) if no prefixes are specified on the command-line. Input Options: *--format* 'FORMAT':: Use echo format FORMAT (same as the options below) *--raw*:: Dump message as is (Note: no delimiters are printed) *--ascii,-A*:: Print ASCII part of message delimited by newline. All non-ascii characters replaced by dot. *--quoted,-Q*:: Print each message on separate line in double quotes with C-like character escaping *--msgpack*:: Print each message as msgpacked string (raw type). This is useful for programmatic parsing. Output Options: *--interval,-i* 'SEC':: Send message (or request) every SEC seconds *--delay,-d* 'SEC':: Wait for SEC seconds before sending message (useful for one-shot PUB sockets) *--data,-D* 'DATA':: Send DATA to the socket and quit for PUB, PUSH, PAIR, BUS socket. Use DATA to reply for REP or RESPONDENT socket. Send DATA as request for REQ or SURVEYOR socket. *--file,-F* 'PATH':: Same as --data but get data from file PATH EXAMPLES -------- The ping-pong with nn_req/nn_rep sockets (must be run simultaneously): nanocat --rep --bind tcp://127.0.0.1:1234 --data pong --format ascii nanocat --req --connect tcp://127.0.0.1:1234 --data ping --format ascii Or in shorter to write form: nn_rep -L1234 -Dpong -A nn_req -l1234 -Dping -A Do periodic requests once a second: nn_req -l1234 -Dping -A -i 1 The rep socket that never reply (no -D option), may be used to check if resending the requests is actually work: nanocat --rep --connect ipc:///var/run/app/req.socket Send an output of the ls to whatever would connect to 127.0.0.1:1234 then exit: ls | nanocat --push -L1234 -F- Send heartbeats to imaginary monitoring service: nanocat --pub --connect tpc://monitoring.example.org -D"I am alive!" --interval 10 SEE ALSO -------- linknanomsg:nanomsg[7] AUTHORS ------- Paul Colomiets nanomsg-0.8-beta/doc/tcpmuxd.txt0000664000175000017500000000132612623652600017636 0ustar00travistravis00000000000000tcpmuxd(1) ========== NAME ---- tcpmuxd - TCP muliplexer daemon SYNOPSIS -------- tcpmuxd PORT DESCRIPTION ----------- THIS IS AN EXPERIMENTAL FEATURE. DO NOT USE. THE FUNCTIONALITY IS SUBJECT TO CHANGE WITHOUT PRIOR NOTICE. TCP multiplexer daemon listens on all network interfaces on TCP port specified by argument PORT. On each incoming connection it performs TCPMUX handshake as defined in RFC 1078. Then it hands the connection to the application bound to the service name specified by the client (see linknanomsg:tcpmux[7] for more details). OPTIONS ------- There are no options defined. SEE ALSO -------- linknanomsg:tcpmux[7] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_errno.txt0000664000175000017500000000224712623652600017775 0ustar00travistravis00000000000000nn_errno(3) =========== NAME ---- nn_errno - retrieve the current errno SYNOPSIS -------- *#include * *int nn_errno (void);* DESCRIPTION ----------- Returns value of 'errno' for the current thread. On most systems, 'errno' can be accessed directly and this function is not needed. However, on Windows, there are multiple implementations of the CRT library (single-threaded, multi-threaded, release, debug) and each of them has its own instance of 'errno'. Thus, if nanomsg library and the application that uses it link with different versions of CRT library, they don't share same instance of 'errno'. Consequently, error codes set by nanomsg cannot be accessed by the application. To overcome this problem, application can use _nn_errno()_ function to retrieve the nanomsg's value of 'errno'. RETURN VALUE ------------ Returns value of 'errno' for the current thread. ERRORS ------ No errors are defined. EXAMPLE ------- ---- rc = nn_send (s, "ABC", 3, 0); if (rc < 0) printf ("nn_send failed with error code %d\n", nn_errno ()); ---- SEE ALSO -------- linknanomsg:nn_strerror[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_strerror.txt0000664000175000017500000000137612623652600020534 0ustar00travistravis00000000000000nn_strerror(3) ============== NAME ---- nn_strerror - convert an error number into human-readable string SYNOPSIS -------- *#include * *const char *nn_strerror (int 'errnum');* DESCRIPTION ----------- Converts error number (errno) into a human-readable string. As opposed to 'strerror(3)' this function handles nanomsg-specific errors in addition to standard system errors. RETURN VALUE ------------ Return error message string. ERRORS ------ No errors are defined. EXAMPLE ------- ---- rc = nn_send (s, "ABC", 3, 0); if (rc < 0) printf ("nn_send failed: %s\n", nn_strerror (errno)); ---- SEE ALSO -------- linknanomsg:nn_errno[3] linknanomsg:nn_symbol[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_symbol.txt0000664000175000017500000000353712623652600020160 0ustar00travistravis00000000000000nn_symbol(3) ============ NAME ---- nn_symbol - query the names and values of nanomsg symbols SYNOPSIS -------- *#include * *const char *nn_symbol (int 'i', int '*value');* DESCRIPTION ----------- Retrieves the symbol name and value at index 'i'. Indices start at 0. An index has no significance to its associated symbol; the mappings may change between library versions. Typically a client will iterate through the symbols until nn_symbol returns NULL in order to collect all the symbols. All symbols exposed by 'nn_symbol' are available directly in the C API, generally as preprocessor macros. Thus, this function is useful mostly for language bindings that can't parse the header file and rely on retrieving the symbols in the runtime. Note that the NN_MSG symbol is not exported by the _nn_symbol_ function. First, it is a pointer rather than an integer; second, the symbol is not supposed to be exported from language bindings to the user. Instead, language bindings should provide the zero-copy functionality in a language-specific way, if at all (zero-copy functionality may not make sense for some languages/bindings). RETURN VALUE ------------ If 'i' is valid, returns the name of the symbol at that index. If the pointer 'value' is not NULL, the symbol's value is stored there. If 'i' is out-of-range, nn_symbol returns NULL and sets 'errno' to EINVAL. ERRORS ------ *EINVAL*:: The passed index 'i' was out-of-range; it was less than zero or greater-than-or- equal-to the number of symbols. EXAMPLE ------- ---- int value, i; for (i = 0; ; ++i) { const char* name = nn_symbol (i, &value); if (name == NULL) break; printf ("'%s' = %d\n", name, value); } ---- SEE ALSO -------- linknanomsg:nn_symbol_info[3] linknanomsg:nn_errno[3] linknanomsg:nn_strerror[3] linknanomsg:nanomsg[7] AUTHORS ------- Evan Wies nanomsg-0.8-beta/doc/nn_symbol_info.txt0000664000175000017500000001035412623652600021166 0ustar00travistravis00000000000000nn_symbol_info(3) ================= NAME ---- nn_symbol_info - query the names and properties of nanomsg symbols SYNOPSIS -------- *#include * *int nn_symbol_info (int 'i', struct nn_symbol_properties '*buf', int 'buflen');* DESCRIPTION ----------- Retrieves the symbol name and value at index 'i'. Indices start at 0. An index has no significance to its associated symbol; the mappings may change between library versions. The nn_symbol_properties has the following definition: ---- struct nn_symbol_properties { /* The constant value */ int value; /* The constant name */ const char* name; /* The constant namespace, or zero for namespaces themselves */ int ns; /* The option type for socket option constants */ int type; /* The unit for the option value for socket option constants */ int unit; }; ---- More structure members may be added in future, but input pointer will be written only up to 'buflen' so ABI is forward-compatible. Typically a client will iterate through the symbols until nn_symbol_info returns NULL in order to collect all the symbols. All symbols exposed by 'nn_symbol_info' are available directly in the C API, generally as preprocessor macros. Thus, this function is useful mostly for language bindings that can't parse the header file and rely on retrieving the symbols in the runtime. Note that the NN_MSG symbol is not exported by the 'nn_symbol_info' function. First, it is a pointer rather than an integer; second, the symbol is not supposed to be exported from language bindings to the user. Instead, language bindings should provide the zero-copy functionality in a language-specific way, if at all (zero-copy functionality may not make sense for some languages/bindings). AVAILABLE NAMESPACES -------------------- *NN_NS_NAMESPACE*:: Equals to zero and denotes the NN_NS_* constants themselves *NN_NS_VERSION*:: Nanomsg version constants *NN_NS_DOMAIN*:: Socket domain (or address family) constants AF_SP, AF_SP_RAW *NN_NS_TRANSPORT*:: Transport name constants (used for socket options mainly) *NN_NS_PROTOCOL*:: Socket protocol constants *NN_NS_OPTION_LEVEL*:: Socket option level constants (NN_SOL_SOCKET) *NN_NS_SOCKET_OPTION*:: Socket options for NN_SOL_SOCKET level *NN_NS_TRANSPORT_OPTION*:: Socket options for transport level (used with transport constants) *NN_NS_OPTION_TYPE*:: The option types (described below) *NN_NS_FLAG*:: The nn_send/nn_recv flags (only NN_DONTWAIT for now) *NN_NS_ERROR*:: The errno values *NN_NS_LIMIT*:: Various nanomsg limits (only NN_SOCKADDR_MAX for now) *NN_NS_EVENT*:: Event flags (bit mask) for use with nn_poll (NN_POLLIN, NN_POLLOUT) AVAILABLE OPTION TYPES ---------------------- *NN_TYPE_NONE*:: No type, is returned for constants that are not socket options *NN_TYPE_INT*:: The integer type *NN_TYPE_STR*:: String (char *) type More types may be added in future nanomsg. You may enumerate all of them using the 'nn_symbol_info' itself by checking 'NN_NS_OPTION_TYPE' namespace. AVAILABLE OPTION UNITS ---------------------- *NN_UNIT_NONE*:: No unit, is returned for constants that are not socket options, or do not have any meaningful unit (strings, integer values) *NN_UNIT_BYTES*:: The option value is expressed in bytes *NN_UNIT_MILLISECONDS*:: The option value is expressed in milliseconds *NN_UNIT_PRIORITY*:: The option value is a priority, an integer from 1 to 16 *NN_UNIT_BOOLEAN*:: The option value is boolean, an integer 0 or 1 More types may be added in future nanomsg. You may enumerate all of them using the 'nn_symbol_info' itself by checking 'NN_NS_OPTION_TYPE' namespace. RETURN VALUE ------------ If 'i' is valid, returns the number of bytes stored at the structure. The maximum value that can be returned is 'buflen'. If 'i' is out-of-range, nn_symbol_info returns zero. EXAMPLE ------- ---- int i; for (i = 0; ; ++i) { struct nn_symbol_properties sym; int rc = nn_symbol_info (i, &sym, sizeof (sym)); if(rc == 0) break; assert (rc == sizeof (sym)); printf ("'%s' = %d\n", sym.name, sym.value); } ---- SEE ALSO -------- linknanomsg:nn_symbol[3] linknanomsg:nn_errno[3] linknanomsg:nn_strerror[3] linknanomsg:nanomsg[7] AUTHORS ------- Paul Colomiets Garrett D'Amore nanomsg-0.8-beta/doc/nn_term.txt0000664000175000017500000000227112623652600017614 0ustar00travistravis00000000000000nn_term(3) ========== NAME ---- nn_term - notify all sockets about process termination SYNOPSIS -------- *#include * *void nn_term (void);* DESCRIPTION ----------- To help with shutdown of multi-threaded programs nanomsg provides the _nn_term()_ function which informs all the open sockets that process termination is underway. If a socket is blocked inside a blocking function, such as linknanomsg:nn_recv[3], it will be unblocked and ETERM error will be returned to the user. Similarly, any subsequent attempt to invoke a socket function other than linknanomsg:nn_close[3] after _nn_term()_ was called will result in ETERM error. If waiting for _NN_SNDFD_ or _NN_RCVFD_ using a polling function, such as _poll()_ or _select()_, the call will unblock with both _NN_SNDFD_ and _NN_RCVFD_ signaled. The _nn_term()_ function itself is non-blocking. EXAMPLE ------- ---- s = nn_socket (AF_SP, NN_PAIR); nn_term (); rc = nn_send (s, "ABC", 3, 0); assert (rc == -1 && errno == ETERM); ---- SEE ALSO -------- linknanomsg:nn_close[3] linknanomsg:nn_send[3] linknanomsg:nn_recv[3] linknanomsg:nn_getsockopt[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_allocmsg.txt0000664000175000017500000000314012623652600020442 0ustar00travistravis00000000000000nn_allocmsg(3) ============== NAME ---- nn_allocmsg - allocate a message SYNOPSIS -------- *#include * *void *nn_allocmsg (size_t 'size', int 'type');* DESCRIPTION ----------- Allocate a message of the specified 'size' to be sent in zero-copy fashion. The content of the message is undefined after allocation and it should be filled in by the user. While linknanomsg:nn_send[3] and linknanomsg:nn_sendmsg[3] allow to send arbitrary buffers, buffers allocated using _nn_allocmsg()_ can be more efficient for large messages as they allow for using zero-copy techniques. 'type' parameter specifies type of allocation mechanism to use. Zero is the default one, however, individual transport mechanisms may define their own allocation mechanisms, such as allocating in shared memory or allocating a memory block pinned down to a physical memory address. Such allocation, when used with the transport that defines them, should be more efficient than the default allocation mechanism. RETURN VALUE ------------ If the function succeeds pointer to newly allocated buffer is returned. Otherwise, NULL is returned and 'errno' is set to to one of the values defined below. ERRORS ------ *EINVAL*:: Supplied allocation 'type' is invalid. *ENOMEM*:: Not enough memory to allocate the message. EXAMPLE ------- ---- void *buf = nn_allocmsg (12, 0); memcpy (buf, "Hello world!", 12); nn_send (s, &buf, NN_MSG, 0); ---- SEE ALSO -------- linknanomsg:nn_freemsg[3] linknanomsg:nn_reallocmsg[3] linknanomsg:nn_send[3] linknanomsg:nn_sendmsg[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_reallocmsg.txt0000664000175000017500000000167412623652600021003 0ustar00travistravis00000000000000nn_reallocmsg(3) ================ NAME ---- nn_reallocmsg - reallocate a message SYNOPSIS -------- *#include * *void *nn_reallocmsg (void *'msg', size_t 'size');* DESCRIPTION ----------- Reallocate a message previously allocated by linknanomsg:nn_allocmsg[3] or received from a peer using NN_MSG mechanism. Note that as with the standard _realloc_, the operation may involve copying the data in the buffer. RETURN VALUE ------------ If the function succeeds pointer to newly allocated buffer is returned. Otherwise, NULL is returned and 'errno' is set to to one of the values defined below. ERRORS ------ *ENOMEM*:: Not enough memory to allocate the message. EXAMPLE ------- ---- void *buf = nn_allocmsg (12, 0); void *newbuf = nn_reallocmsg (buf, 20); nn_freemsg (newbuf); ---- SEE ALSO -------- linknanomsg:nn_allocmsg[3] linknanomsg:nn_freemsg[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_freemsg.txt0000664000175000017500000000204112623652600020270 0ustar00travistravis00000000000000nn_freemsg(3) ============= NAME ---- nn_freemsg - deallocate a message SYNOPSIS -------- *#include * *int nn_freemsg (void '*msg');* DESCRIPTION ----------- Deallocates a message allocated using linknanomsg:nn_allocmsg[3] function or received via linknanomsg:nn_recv[3] or linknanomsg:nn_recvmsg[3] function. While linknanomsg:nn_recv[3] and linknanomsg:nn_recvmsg[3] allow to receive data into arbitrary buffers, using library-allocated buffers can be more efficient for large messages as it allows for using zero-copy techniques. RETURN VALUE ------------ If the function succeeds zero is returned. Otherwise, -1 is returned and 'errno' is set to to one of the values defined below. ERRORS ------ *EFAULT*:: The message pointer is invalid. EXAMPLE ------- ---- void *buf; nn_recv (s, &buf, NN_MSG, 0); nn_freemsg (buf); ---- SEE ALSO -------- linknanomsg:nn_allocmsg[3] linknanomsg:nn_reallocmsg[3] linknanomsg:nn_recv[3] linknanomsg:nn_recvmsg[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_socket.txt0000664000175000017500000000435212623652600020137 0ustar00travistravis00000000000000nn_socket(3) ============ NAME ---- nn_socket - create an SP socket SYNOPSIS -------- *#include * *int nn_socket (int 'domain', int 'protocol');* DESCRIPTION ----------- Creates an SP socket with specified 'domain' and 'protocol'. Returns a file descriptor for the newly created socket. Following domains are defined at the moment: *AF_SP*:: Standard full-blown SP socket. *AF_SP_RAW*:: Raw SP socket. Raw sockets omit the end-to-end functionality found in AF_SP sockets and thus can be used to implement intermediary devices in SP topologies. 'protocol' parameter defines the type of the socket, which in turn determines the exact semantics of the socket. Check manual pages for individual SP protocols to get the list of available socket types. The newly created socket is initially not associated with any endpoints. In order to establish a message flow at least one endpoint has to be added to the socket using linknanomsg:nn_bind[3] or linknanomsg:nn_connect[3] function. Also note that 'type' argument as found in standard _socket(2)_ function is omitted from _nn_socket_. All the SP sockets are message-based and thus of _SOCK_SEQPACKET_ type. RETURN VALUE ------------ If the function succeeds file descriptor of the new socket is returned. Otherwise, -1 is returned and 'errno' is set to to one of the values defined below. Note that file descriptors returned by _nn_socket_ function are not standard file descriptors and will exhibit undefined behaviour when used with system functions. Moreover, it may happen that a system file descriptor and file descriptor of an SP socket will incidentally collide (be equal). ERRORS ------ *EAFNOSUPPORT*:: Specified address family is not supported. *EINVAL*:: Unknown protocol. *EMFILE*:: The limit on the total number of open SP sockets or OS limit for file descriptors has been reached. *ETERM*:: The library is terminating. EXAMPLE ------- ---- int s = nn_socket (AF_SP, NN_PUB); assert (s >= 0); ---- SEE ALSO -------- linknanomsg:nn_pubsub[7] linknanomsg:nn_reqrep[7] linknanomsg:nn_pipeline[7] linknanomsg:nn_survey[7] linknanomsg:nn_bus[7] linknanomsg:nn_bind[3] linknanomsg:nn_connect[3] linknanomsg:nn_close[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_close.txt0000664000175000017500000000205412623652600017751 0ustar00travistravis00000000000000nn_close(3) =========== NAME ---- nn_close - close an SP socket SYNOPSIS -------- *#include * *int nn_close (int 's');* DESCRIPTION ----------- Closes the socket 's'. Any buffered inbound messages that were not yet received by the application will be discarded. The library will try to deliver any outstanding outbound messages for the time specified by _NN_LINGER_ socket option. The call will block in the meantime. RETURN VALUE ------------ If the function succeeds zero is returned. Otherwise, -1 is returned and 'errno' is set to to one of the values defined below. ERRORS ------ *EBADF*:: The provided socket is invalid. *EINTR*:: Operation was interrupted by a signal. The socket is not fully closed yet. Operation can be re-started by calling _nn_close()_ again. EXAMPLE ------- ---- int s = nn_socket (AF_SP, NN_PUB); assert (s >= 0); int rc = nn_close (s); assert (rc == 0); ---- SEE ALSO -------- linknanomsg:nn_socket[3] linknanomsg:nn_setsockopt[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_getsockopt.txt0000664000175000017500000001462312623652600021033 0ustar00travistravis00000000000000nn_getsockopt(3) ================ NAME ---- nn_getsockopt - retrieve a socket option SYNOPSIS -------- *#include * *int nn_getsockopt (int 's', int 'level', int 'option', void '*optval', size_t '*optvallen');* DESCRIPTION ----------- Retrieves the value for the 'option'. The 'level' argument specifies the protocol level at which the option resides. For generic socket-level options use _NN_SOL_SOCKET_ level. For socket-type-specific options use socket type for 'level' argument (e.g. _NN_SUB_). For transport-specific options use ID of the transport as the 'level' argument (e.g. _NN_TCP_). The value is stored in the buffer pointed to by 'optval' argument. Size of the buffer is specified by the 'optvallen' argument. If the size of the option is greater than size of the buffer, the value will be silently truncated. Otherwise, the 'optvallen' will be modified to indicate the actual length of the option. __ header defines generic socket-level options (_NN_SOL_SOCKET_ level). The options are as follows: *NN_DOMAIN*:: Returns the domain constant as it was passed to _nn_socket()_. *NN_PROTOCOL*:: Returns the protocol constant as it was passed to _nn_socket()_. *NN_LINGER*:: Specifies how long the socket should try to send pending outbound messages after _nn_close()_ have been called, in milliseconds. Negative value means infinite linger. The type of the option is int. Default value is 1000 (1 second). *NN_SNDBUF*:: Size of the send buffer, in bytes. To prevent blocking for messages larger than the buffer, exactly one message may be buffered in addition to the data in the send buffer. The type of this option is int. Default value is 128kB. *NN_RCVBUF*:: Size of the receive buffer, in bytes. To prevent blocking for messages larger than the buffer, exactly one message may be buffered in addition to the data in the receive buffer. The type of this option is int. Default value is 128kB. *NN_RCVMAXSIZE*:: Maximum message size that can be received, in bytes. Negative value means that the received size is limited only by available addressable memory. The type of this option is int. Default is 1024kB. *NN_SNDTIMEO*:: The timeout for send operation on the socket, in milliseconds. If message cannot be sent within the specified timeout, EAGAIN error is returned. Negative value means infinite timeout. The type of the option is int. Default value is -1. *NN_RCVTIMEO*:: The timeout for recv operation on the socket, in milliseconds. If message cannot be received within the specified timeout, EAGAIN error is returned. Negative value means infinite timeout. The type of the option is int. Default value is -1. *NN_RECONNECT_IVL*:: For connection-based transports such as TCP, this option specifies how long to wait, in milliseconds, when connection is broken before trying to re-establish it. Note that actual reconnect interval may be randomised to some extent to prevent severe reconnection storms. The type of the option is int. Default value is 100 (0.1 second). *NN_RECONNECT_IVL_MAX*:: This option is to be used only in addition to _NN_RECONNECT_IVL_ option. It specifies maximum reconnection interval. On each reconnect attempt, the previous interval is doubled until _NN_RECONNECT_IVL_MAX_ is reached. Value of zero means that no exponential backoff is performed and reconnect interval is based only on _NN_RECONNECT_IVL_. If _NN_RECONNECT_IVL_MAX_ is less than _NN_RECONNECT_IVL_, it is ignored. The type of the option is int. Default value is 0. *NN_SNDPRIO*:: Retrieves outbound priority currently set on the socket. This option has no effect on socket types that send messages to all the peers. However, if the socket type sends each message to a single peer (or a limited set of peers), peers with high priority take precedence over peers with low priority. The type of the option is int. Highest priority is 1, lowest priority is 16. Default value is 8. *NN_RCVPRIO*:: Sets inbound priority for endpoints subsequently added to the socket. This option has no effect on socket types that are not able to receive messages. When receiving a message, messages from peer with higher priority are received before messages from peer with lower priority. The type of the option is int. Highest priority is 1, lowest priority is 16. Default value is 8. *NN_IPV4ONLY*:: If set to 1, only IPv4 addresses are used. If set to 0, both IPv4 and IPv6 addresses are used. The type of the option is int. Default value is 1. *NN_SNDFD*:: Retrieves a file descriptor that is readable when a message can be sent to the socket. The descriptor should be used only for polling and never read from or written to. The type of the option is same as the type of file descriptor on the platform. That is, int on POSIX-complaint platforms and SOCKET on Windows. The descriptor becomes invalid and should not be used any more once the socket is closed. This socket option is not available for unidirectional recv-only socket types. *NN_RCVFD*:: Retrieves a file descriptor that is readable when a message can be received from the socket. The descriptor should be used only for polling and never read from or written to. The type of the option is same as the type of file descriptor on the platform. That is, int on POSIX-complaint platforms and SOCKET on Windows. The descriptor becomes invalid and should not be used any more once the socket is closed. This socket option is not available for unidirectional send-only socket types. *NN_SOCKET_NAME*:: Socket name for error reporting and statistics. The type of the option is string. Default value is "N" where N is socket integer. *This option is experimental, see linknanomsg:nn_env[7] for details* RETURN VALUE ------------ If the function succeeds zero is returned. Otherwise, -1 is returned and 'errno' is set to to one of the values defined below. ERRORS ------ *EBADF*:: The provided socket is invalid. *ENOPROTOOPT*:: The option is unknown at the level indicated. *ETERM*:: The library is terminating. EXAMPLE ------- ---- int linger; size_t sz = sizeof (linger); nn_getsockopt (s, NN_SOL_SOCKET, NN_LINGER, &linger, &sz); ---- SEE ALSO -------- linknanomsg:nn_socket[3] linknanomsg:nn_setsockopt[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_setsockopt.txt0000664000175000017500000001216212623652600021043 0ustar00travistravis00000000000000nn_setsockopt(3) ================ NAME ---- nn_setsockopt - set a socket option SYNOPSIS -------- *#include * *int nn_setsockopt (int 's', int 'level', int 'option', const void '*optval', size_t 'optvallen');* DESCRIPTION ----------- Sets the value of the 'option'. The 'level' argument specifies the protocol level at which the option resides. For generic socket-level options use _NN_SOL_SOCKET_ level. For socket-type-specific options use socket type for 'level' argument (e.g. _NN_SUB_). For transport-specific options use ID of the transport as the 'level' argument (e.g. _NN_TCP_). The new value is pointed to by 'optval' argument. Size of the option is specified by the 'optvallen' argument. __ header defines generic socket-level options (_NN_SOL_SOCKET_ level). The options are as follows: *NN_LINGER*:: Specifies how long the socket should try to send pending outbound messages after _nn_close()_ have been called, in milliseconds. Negative value means infinite linger. The type of the option is int. Default value is 1000 (1 second). *NN_SNDBUF*:: Size of the send buffer, in bytes. To prevent blocking for messages larger than the buffer, exactly one message may be buffered in addition to the data in the send buffer. The type of this option is int. Default value is 128kB. *NN_RCVBUF*:: Size of the receive buffer, in bytes. To prevent blocking for messages larger than the buffer, exactly one message may be buffered in addition to the data in the receive buffer. The type of this option is int. Default value is 128kB. *NN_RCVMAXSIZE*:: Maximum message size that can be received, in bytes. Negative value means that the received size is limited only by available addressable memory. The type of this option is int. Default is 1024kB. *NN_SNDTIMEO*:: The timeout for send operation on the socket, in milliseconds. If message cannot be sent within the specified timeout, EAGAIN error is returned. Negative value means infinite timeout. The type of the option is int. Default value is -1. *NN_RCVTIMEO*:: The timeout for recv operation on the socket, in milliseconds. If message cannot be received within the specified timeout, EAGAIN error is returned. Negative value means infinite timeout. The type of the option is int. Default value is -1. *NN_RECONNECT_IVL*:: For connection-based transports such as TCP, this option specifies how long to wait, in milliseconds, when connection is broken before trying to re-establish it. Note that actual reconnect interval may be randomised to some extent to prevent severe reconnection storms. The type of the option is int. Default value is 100 (0.1 second). *NN_RECONNECT_IVL_MAX*:: This option is to be used only in addition to _NN_RECONNECT_IVL_ option. It specifies maximum reconnection interval. On each reconnect attempt, the previous interval is doubled until _NN_RECONNECT_IVL_MAX_ is reached. Value of zero means that no exponential backoff is performed and reconnect interval is based only on _NN_RECONNECT_IVL_. If _NN_RECONNECT_IVL_MAX_ is less than _NN_RECONNECT_IVL_, it is ignored. The type of the option is int. Default value is 0. *NN_SNDPRIO*:: Sets outbound priority for endpoints subsequently added to the socket. This option has no effect on socket types that send messages to all the peers. However, if the socket type sends each message to a single peer (or a limited set of peers), peers with high priority take precedence over peers with low priority. The type of the option is int. Highest priority is 1, lowest priority is 16. Default value is 8. *NN_RCVPRIO*:: Sets inbound priority for endpoints subsequently added to the socket. This option has no effect on socket types that are not able to receive messages. When receiving a message, messages from peer with higher priority are received before messages from peer with lower priority. The type of the option is int. Highest priority is 1, lowest priority is 16. Default value is 8. *NN_IPV4ONLY*:: If set to 1, only IPv4 addresses are used. If set to 0, both IPv4 and IPv6 addresses are used. The type of the option is int. Default value is 1. *NN_SOCKET_NAME*:: Socket name for error reporting and statistics. The type of the option is string. Default value is "socket.N" where N is socket integer. *This option is experimental, see linknanomsg:nn_env[7] for details* RETURN VALUE ------------ If the function succeeds zero is returned. Otherwise, -1 is returned and 'errno' is set to to one of the values defined below. ERRORS ------ *EBADF*:: The provided socket is invalid. *ENOPROTOOPT*:: The option is unknown at the level indicated. *EINVAL*:: The specified option value is invalid. *ETERM*:: The library is terminating. EXAMPLE ------- ---- int linger = 1000; nn_setsockopt (s, NN_SOL_SOCKET, NN_LINGER, &linger, sizeof (linger)); nn_setsockopt (s, NN_SUB, NN_SUB_SUBSCRIBE, "ABC", 3); ---- SEE ALSO -------- linknanomsg:nn_socket[3] linknanomsg:nn_getsockopt[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_bind.txt0000664000175000017500000000411012623652600017553 0ustar00travistravis00000000000000nn_bind(3) ========== NAME ---- nn_bind - add a local endpoint to the socket SYNOPSIS -------- *#include * *int nn_bind (int 's', const char '*addr');* DESCRIPTION ----------- Adds a local endpoint to the socket 's'. The endpoint can be then used by other applications to connect to. The 'addr' argument consists of two parts as follows: 'transport'`://`'address'. The 'transport' specifies the underlying transport protocol to use. The meaning of the 'address' part is specific to the underlying transport protocol. For the list of available transport protocols check the list on linknanomsg:nanomsg[7] manual page. Maximum length of the 'addr' parameter is specified by _NN_SOCKADDR_MAX_ defined in '' header file. Note that nn_bind and linknanomsg:nn_connect[3] may be called multiple times on the same socket thus allowing the socket to communicate with multiple heterogeneous endpoints. RETURN VALUE ------------ If the function succeeds positive endpoint ID is returned. Endpoint ID can be later used to remove the endpoint from the socket via linknanomsg:nn_shutdown[3] function. If the function fails, then -1 is returned and 'errno' is set to to one of the values defined below. ERRORS ------ *EBADF*:: The provided socket is invalid. *EMFILE*:: Maximum number of active endpoints was reached. *EINVAL*:: The syntax of the supplied address is invalid. *ENAMETOOLONG*:: The supplied address is too long. *EPROTONOSUPPORT*:: The requested transport protocol is not supported. *EADDRNOTAVAIL*:: The requested endpoint is not local. *ENODEV*:: Address specifies a nonexistent interface. *EADDRINUSE*:: The requested local endpoint is already in use. *ETERM*:: The library is terminating. EXAMPLE ------- ---- s = nn_socket (AF_SP, NN_PUB); eid1 = nn_bind (s, "inproc://test"); eid2 = nn_bind (s, "tcp://127.0.0.1:5560"); ---- SEE ALSO -------- linknanomsg:nn_inproc[7] linknanomsg:nn_ipc[7] linknanomsg:nn_tcp[7] linknanomsg:nn_socket[3] linknanomsg:nn_connect[3] linknanomsg:nn_shutdown[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_connect.txt0000664000175000017500000000376412623652600020306 0ustar00travistravis00000000000000nn_connect(3) ============= NAME ---- nn_connect - add a remote endpoint to the socket SYNOPSIS -------- *#include * *int nn_connect (int 's', const char '*addr');* DESCRIPTION ----------- Adds a remote endpoint to the socket 's'. The library would then try to connect to the specified remote endpoint. The 'addr' argument consists of two parts as follows: 'transport'`://`'address'. The 'transport' specifies the underlying transport protocol to use. The meaning of the 'address' part is specific to the underlying transport protocol. For the list of available transport protocols check the list on linknanomsg:nanomsg[7] manual page. Maximum length of the 'addr' parameter is specified by _NN_SOCKADDR_MAX_ defined in '' header file. Note that nn_connect and linknanomsg:nn_bind[3] may be called multiple times on the same socket thus allowing the socket to communicate with multiple heterogeneous endpoints. RETURN VALUE ------------ If the function succeeds positive endpoint ID is returned. Endpoint ID can be later used to remove the endpoint from the socket via linknanomsg:nn_shutdown[3] function. If the function fails negative value is returned and 'errno' is set to to one of the values defined below. ERRORS ------ *EBADF*:: The provided socket is invalid. *EMFILE*:: Maximum number of active endpoints was reached. *EINVAL*:: The syntax of the supplied address is invalid. *ENAMETOOLONG*:: The supplied address is too long. *EPROTONOSUPPORT*:: The requested transport protocol is not supported. *ENODEV*:: Address specifies a nonexistent interface. *ETERM*:: The library is terminating. EXAMPLE ------- ---- s = nn_socket (AF_SP, NN_PUB); eid1 = nn_connect (s, "ipc:///tmp/test.ipc"); eid2 = nn_connect (s, "tcp://server001:5560"); ---- SEE ALSO -------- linknanomsg:nn_inproc[7] linknanomsg:nn_ipc[7] linknanomsg:nn_tcp[7] linknanomsg:nn_socket[3] linknanomsg:nn_bind[3] linknanomsg:nn_shutdown[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_shutdown.txt0000664000175000017500000000246312623652600020523 0ustar00travistravis00000000000000nn_shutdown(3) ============== NAME ---- nn_shutdown - remove an endpoint from a socket SYNOPSIS -------- *#include * *int nn_shutdown (int 's', int 'how');* DESCRIPTION ----------- Removes an endpoint from socket 's'. 'how' parameter specifies the ID of the endpoint to remove as returned by prior call to linknanomsg:nn_bind[3] or linknanomsg:nn_connect[3]. _nn_shutdown()_ call will return immediately, however, the library will try to deliver any outstanding outbound messages to the endpoint for the time specified by _NN_LINGER_ socket option. RETURN VALUE ------------ If the function succeeds zero is returned. Otherwise, -1 is returned and 'errno' is set to to one of the values defined below. ERRORS ------ *EBADF*:: The provided socket is invalid. *EINVAL*:: The 'how' parameter doesn't correspond to an active endpoint. *EINTR*:: Operation was interrupted by a signal. The endpoint is not fully closed yet. Operation can be re-started by calling _nn_shutdown()_ again. *ETERM*:: The library is terminating. EXAMPLE ------- ---- s = nn_socket (AF_SP, NN_PUB); eid = nn_bind (s, "inproc://test"); nn_shutdown (s, eid); ---- SEE ALSO -------- linknanomsg:nn_socket[3] linknanomsg:nn_bind[3] linknanomsg:nn_connect[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_send.txt0000664000175000017500000000457212623652600017604 0ustar00travistravis00000000000000nn_send(3) ========== NAME ---- nn_send - send a message SYNOPSIS -------- *#include * *int nn_send (int 's', const void '*buf', size_t 'len', int 'flags');* DESCRIPTION ----------- The function will send a message containing the data from buffer pointed to by 'buf' parameter to the socket 's'. The message will be 'len' bytes long. Alternatively, to send a buffer allocated by linknanomsg:nn_allocmsg[3] function set the buf parameter to point to the pointer to the buffer and 'len' parameter to _NN_MSG_ constant. In this case a successful call to _nn_send_ will deallocate the buffer. Trying to deallocate it afterwards will result in undefined behaviour. Which of the peers the message will be sent to is determined by the particular socket type. The 'flags' argument is a combination of the flags defined below: *NN_DONTWAIT*:: Specifies that the operation should be performed in non-blocking mode. If the message cannot be sent straight away, the function will fail with 'errno' set to EAGAIN. RETURN VALUE ------------ If the function succeeds, the number of bytes in the message is returned. Otherwise, -1 is returned and 'errno' is set to to one of the values defined below. ERRORS ------ *EFAULT*:: 'buf' is NULL or 'len' is NN_MSG and the message pointer (pointed to by 'buf') is NULL. *EBADF*:: The provided socket is invalid. *ENOTSUP*:: The operation is not supported by this socket type. *EFSM*:: The operation cannot be performed on this socket at the moment because the socket is not in the appropriate state. This error may occur with socket types that switch between several states. *EAGAIN*:: Non-blocking mode was requested and the message cannot be sent at the moment. *EINTR*:: The operation was interrupted by delivery of a signal before the message was sent. *ETIMEDOUT*:: Individual socket types may define their own specific timeouts. If such timeout is hit, this error will be returned. *ETERM*:: The library is terminating. EXAMPLE ------- Using data directly: ---- nbytes = nn_send (s, "ABC", 3, 0); assert (nbytes == 3); ---- Using a pre-allocated message buffer: ---- void *msg = nn_allocmsg(3, 0); strncpy(msg, "ABC", 3); nbytes = nn_send (s, &msg, NN_MSG, 0); assert (nbytes == 3); ---- SEE ALSO -------- linknanomsg:nn_recv[3] linknanomsg:nn_sendmsg[3] linknanomsg:nn_socket[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_recv.txt0000664000175000017500000000563512623652600017613 0ustar00travistravis00000000000000nn_recv(3) ========== NAME ---- nn_recv - receive a message SYNOPSIS -------- *#include * *int nn_recv (int 's', void '*buf', size_t 'len', int 'flags');* DESCRIPTION ----------- Receive a message from the socket 's' and store it in the buffer referenced by the 'buf' argument. Any bytes exceeding the length specified by the 'len' argument will be truncated. Alternatively, _nanomsg_ can allocate the buffer for you. To do so, let the 'buf' parameter be a pointer to a void* variable (pointer to pointer) to the receive buffer and set the 'len' parameter to _NN_MSG_. If the call is successful the user is responsible for deallocating the message using the linknanomsg:nn_freemsg[3] function. The 'flags' argument is a combination of the flags defined below: *NN_DONTWAIT*:: Specifies that the operation should be performed in non-blocking mode. If the message cannot be received straight away, the function will fail with 'errno' set to EAGAIN. RETURN VALUE ------------ If the function succeeds number of bytes in the message is returned. Otherwise, -1 is returned and 'errno' is set to to one of the values defined below. ERRORS ------ *EBADF*:: The provided socket is invalid. *ENOTSUP*:: The operation is not supported by this socket type. *EFSM*:: The operation cannot be performed on this socket at the moment because socket is not in the appropriate state. This error may occur with socket types that switch between several states. *EAGAIN*:: Non-blocking mode was requested and there's no message to receive at the moment. *EINTR*:: The operation was interrupted by delivery of a signal before the message was received. *ETIMEDOUT*:: Individual socket types may define their own specific timeouts. If such timeout is hit this error will be returned. *ETERM*:: The library is terminating. EXAMPLES -------- Receiving a message into a buffer allocated by the user:: This example code will retrieve a message of either 100 bytes or less. If a larger message was sent it will be truncated to 100 bytes. ---- char buf [100]; nbytes = nn_recv (s, buf, sizeof (buf), 0); ---- Receiving a message into a buffer allocated by _nanomsg_:: The following will get a message from the pipe with a buffer allocated by the system. It is large enough to accommodate the entire message. This is a good way to get the entire message without truncating if the size of the message is unknown. It is the user's responsibility to call linknanomsg:nn_freemsg[3] after processing the message. ---- void *buf = NULL; nbytes = nn_recv (s, &buf, NN_MSG, 0); if (nbytes < 0) { /* handle error */ ... } else { /* process message */ ... nn_freemsg (buf); } ---- Note that this can be more efficient than manually allocating a buffer since it is a zero-copy operation. SEE ALSO -------- linknanomsg:nn_send[3] linknanomsg:nn_recvmsg[3] linknanomsg:nn_socket[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_sendmsg.txt0000664000175000017500000001002312623652600020277 0ustar00travistravis00000000000000nn_sendmsg(3) ============= NAME ---- nn_sendmsg - fine-grained alternative to nn_send SYNOPSIS -------- *#include * *int nn_sendmsg (int 's', const struct nn_msghdr '*msghdr', int 'flags');* DESCRIPTION ----------- Sends data specified by 'msghdr' parameter to socket 's' along with any additional control data. 'msghdr' structure should be nullified before being used. Structure 'nn_msghdr' contains at least following members: struct nn_iovec *msg_iov; int msg_iovlen; void *msg_control; size_t msg_controllen; 'msg_iov' points to a scatter array of buffers to send. 'msg_iovlen' specifies the size of the array. 'msg_control' points to the buffer containing control information to be associated with the message being sent. 'msg_controllen' specifies the length of the buffer. If there's no control information to send, 'msg_control' should be set to NULL. For detailed discussion of how to set control data check linknanomsg:nn_cmsg[3] man page. Structure 'nn_iovec' defines one element in the scatter array (i.e. a buffer to send to the socket) and contains following members: void *iov_base; size_t iov_len; Alternatively, to send a buffer allocated by linknanomsg:nn_allocmsg[3] function set 'iov_base' to point to the pointer to the buffer and 'iov_len' to _NN_MSG_ constant. In this case a successful call to _nn_sendmsg_ will deallocate the buffer. Trying to deallocate it afterwards will result in undefined behaviour. Also, scatter array in _nn_msghdr_ structure can contain only one element in this case. To which of the peers will the message be sent to is determined by the particular socket type. The 'flags' argument is a combination of the flags defined below: *NN_DONTWAIT*:: Specifies that the operation should be performed in non-blocking mode. If the message cannot be sent straight away, the function will fail with 'errno' set to EAGAIN. RETURN VALUE ------------ If the function succeeds number of bytes in the message is returned. Otherwise, -1 is returned and 'errno' is set to to one of the values defined below. ERRORS ------ *EINVAL*:: Either 'msghdr' is NULL, there are multiple scatter buffers but length is set to 'NN_MSG' for one of them, or the sum of 'iov_len' values for the scatter buffers overflows 'size_t'. These are early checks and no pre-allocated message is freed in this case. *EMSGSIZE*:: msghdr->msg_iovlen is negative. This is an early check and no pre-allocated message is freed in this case. *EFAULT*:: The supplied pointer for the pre-allocated message buffer or the scatter buffer is NULL, or the length for the scatter buffer is 0. *EBADF*:: The provided socket is invalid. *ENOTSUP*:: The operation is not supported by this socket type. *EFSM*:: The operation cannot be performed on this socket at the moment because socket is not in the appropriate state. This error may occur with socket types that switch between several states. *EAGAIN*:: Non-blocking mode was requested and the message cannot be sent at the moment. *EINTR*:: The operation was interrupted by delivery of a signal before the message was sent. *ETIMEDOUT*:: Individual socket types may define their own specific timeouts. If such timeout is hit this error will be returned. *ETERM*:: The library is terminating. EXAMPLE ------- Usage of multiple scatter buffers: ---- struct nn_msghdr hdr; struct nn_iovec iov [2]; iov [0].iov_base = "Hello"; iov [0].iov_len = 5; iov [1].iov_base = "World"; iov [1].iov_len = 5; memset (&hdr, 0, sizeof (hdr)); hdr.msg_iov = iov; hdr.msg_iovlen = 2; nn_sendmsg (s, &hdr, 0); ---- Usage of a single message: ---- void *msg; struct nn_msghdr hdr; struct nn_iovec iov; msg = nn_allocmsg(12, 0); strcpy(msg, "Hello World"); iov.iov_base = &msg; iov.iov_len = NN_MSG; memset (&hdr, 0, sizeof (hdr)); hdr.msg_iov = &iov; hdr.msg_iovlen = 1; nn_sendmsg (s, &hdr, 0); ---- SEE ALSO -------- linknanomsg:nn_send[3] linknanomsg:nn_recvmsg[3] linknanomsg:nn_allocmsg[3] linknanomsg:nn_freemsg[3] linknanomsg:nn_cmsg[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_recvmsg.txt0000664000175000017500000000624212623652600020315 0ustar00travistravis00000000000000nn_recvmsg(3) ============= NAME ---- nn_recvmsg - fine-grained alternative to nn_recv SYNOPSIS -------- *#include * *NN_EXPORT int nn_recvmsg (int 's', struct nn_msghdr '*msghdr', int 'flags');* DESCRIPTION ----------- Receives a message from socket 's' into buffers specified by 'msghdr' parameter along with any additional control data. 'msghdr' parameter should be nullified before being used. Structure 'nn_msghdr' contains at least following members: struct nn_iovec *msg_iov; int msg_iovlen; void *msg_control; size_t msg_controllen; 'msg_iov' points to a gather array of buffers to fill in. 'msg_iovlen' specifies the size of the array. 'msg_control' points to the buffer to hold control information associated with the received message. 'msg_controllen' specifies the length of the buffer. If the control information should not be retrieved, set 'msg_control' parameter to NULL. For detailed discussion of how to parse the control information check linknanomsg:nn_cmsg[3] man page. Structure 'nn_iovec' defines one element in the gather array (a buffer to be filled in by message data) and contains following members: void *iov_base; size_t iov_len; Alternatively, _nanomsg_ library can allocate the buffer for you. To do so, let the 'iov_base' point to void* variable to receive the buffer and set 'iov_len' to _NN_MSG_. After successful completion user is responsible for deallocating the message using linknanomsg:nn_freemsg[3] function. Gather array in _nn_msghdr_ structure can contain only one element in this case. The 'flags' argument is a combination of the flags defined below: *NN_DONTWAIT*:: Specifies that the operation should be performed in non-blocking mode. If the message cannot be received straight away, the function will fail with 'errno' set to EAGAIN. RETURN VALUE ------------ If the function succeeds number of bytes in the message is returned. Otherwise, -1 is returned and 'errno' is set to to one of the values defined below. ERRORS ------ *EBADF*:: The provided socket is invalid. *ENOTSUP*:: The operation is not supported by this socket type. *EFSM*:: The operation cannot be performed on this socket at the moment because socket is not in the appropriate state. This error may occur with socket types that switch between several states. *EAGAIN*:: Non-blocking mode was requested and there's no message to receive at the moment. *EINTR*:: The operation was interrupted by delivery of a signal before the message was received. *ETIMEDOUT*:: Individual socket types may define their own specific timeouts. If such timeout is hit this error will be returned. *ETERM*:: The library is terminating. EXAMPLE ------- ---- struct nn_msghdr hdr; struct nn_iovec iov [2]; char buf0 [4]; char buf1 [2]; iov [0].iov_base = buf0; iov [0].iov_len = sizeof (buf0); iov [1].iov_base = buf1; iov [1].iov_len = sizeof (buf1); memset (&hdr, 0, sizeof (hdr)); hdr.msg_iov = iov; hdr.msg_iovlen = 2; nn_recvmsg (s, &hdr, 0); ---- SEE ALSO -------- linknanomsg:nn_recv[3] linknanomsg:nn_sendmsg[3] linknanomsg:nn_allocmsg[3] linknanomsg:nn_freemsg[3] linknanomsg:nn_cmsg[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_device.txt0000664000175000017500000000274212623652600020107 0ustar00travistravis00000000000000nn_device(3) ============ NAME ---- nn_device - start a device SYNOPSIS -------- *#include * *int nn_device (int 's1', int 's2');* DESCRIPTION ----------- Starts a device to forward messages between two sockets. If both sockets are valid, _nn_device_ function loops and sends and messages received from 's1' to 's2' and vice versa. If only one socket is valid and the other is negative, _nn_device_ works in a "loopback" mode -- it loops and sends any messages received from the socket back to itself. To break the loop and make _nn_device_ function exit use linknanomsg:nn_term[3] function. RETURN VALUE ------------ The function loops until it hits an error. In such case it returns -1 and sets 'errno' to one of the values defined below. ERRORS ------ *EBADF*:: One of the provided sockets is invalid. *EINVAL*:: Either one of the socket is not an AF_SP_RAW socket; or the two sockets don't belong to the same protocol; or the directionality of the sockets doesn't fit (e.g. attempt to join two SINK sockets to form a device). *EINTR*:: The operation was interrupted by delivery of a signal. *ETERM*:: The library is terminating. EXAMPLE ------- ---- int s1 = nn_socket (AF_SP_RAW, NN_REQ); nn_bind (s1, "tcp://127.0.0.1:5555"); int s2 = nn_socket (AF_SP_RAW, NN_REP); nn_bind (s2, "tcp://127.0.0.1:5556"); nn_device (s1, s2); ---- SEE ALSO -------- linknanomsg:nn_socket[3] linknanomsg:nn_term[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_cmsg.txt0000664000175000017500000000436312623652600017602 0ustar00travistravis00000000000000nn_cmsg(3) ========== NAME ---- nn_cmsg - access control information SYNOPSIS -------- *#include * *struct nn_cmsghdr *NN_CMSG_FIRSTHDR(struct nn_msghdr '*hdr');* *struct nn_cmsghdr *NN_CMSG_NXTHDR(struct nn_msghdr '*hdr', struct nn_cmsghdr '*cmsg');* *unsigned char *NN_CMSG_DATA(struct nn_cmsghdr '*cmsg');* *size_t NN_CMSG_SPACE(size_t 'len');* *size_t NN_CMSG_LEN(size_t 'len');* DESCRIPTION ----------- These functions can be used to iterate over ancillary data attached to a message. Structure 'nn_cmsghdr' represents a single ancillary property and contains following members: size_t cmsg_len; int cmsg_level; int cmsg_type; 'cmsg_len' is the size of the property data, including the preceding nn_cmsghdr structure. 'cmsg_level' is the level of the property; same values can be used as with linknanomsg:nn_getsockopt[3] and linknanomsg:nn_setsockopt[3]. 'cmsg_type' is the name of the property. These names are specific for each level. _NN_CMSG_FIRSTHDR_ returns a pointer to the first nn_cmsghdr in the control buffer in the supplied nn_msghdr structure. _NN_CMSG_NXTHDR_ returns the next nn_cmsghdr after the supplied nn_cmsghdr. Returns NULL if there isn't enough space in the buffer. _NN_CMSG_DATA_ returns a pointer to the data associated with supplied nn_cmsghdr. _NN_CMSG_SPACE_ returns the number of bytes occupied by nn_cmsghdr with payload of the specified length. _NN_CMSG_LEN_ returns the value to store in the cmsg_len member of the cmsghdr structure, taking into account any necessary alignment. EXAMPLE ------- Iterating over ancillary properties: ---- struct nn_cmsghdr *hdr = NN_CMSG_FIRSTHDR (&msg); while (hdr != NULL) { size_t len = hdr->cmsg_len - sizeof (nn_cmsghdr); printf ("level: %d property: %d length: %dB data: ", (int) hdr->cmsg_level, (int) hdr->cmsg_type, (int) len); unsigned char *data = NN_CMSG_DATA(hdr); while (len) { printf ("%02X", *data); ++data; --len; } printf ("\n"); hdr = NN_CMSG_NXTHDR (&msg, hdr); } ---- SEE ALSO -------- linknanomsg:nn_sendmsg[3] linknanomsg:nn_recvmsg[3] linknanomsg:nn_getsockopt[3] linknanomsg:nn_setsockopt[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_poll.txt0000664000175000017500000000476512623652600017625 0ustar00travistravis00000000000000nn_poll(3) ========== NAME ---- nn_poll - poll a set of SP sockets for readability and/or writability SYNOPSIS -------- *#include * *int nn_poll (struct nn_pollfd *fds, int nfds, int timeout);* DESCRIPTION ----------- The function checks a set of SP socket and reports whether it's possible to send a message to the socket and/or receive a message from each socket. 'fds' argument is an array of nn_pollfd structures with 'nfds' argument specifying the size of the array: ---- struct nn_pollfd { int fd; short events; short revents; }; ---- Each entry in the array represents an SP socket to check. 'events' field specifies which events to check for. The value is a bitwise combination of the following values: *NN_POLLIN*:: Check whether at least one message can be received from the 'fd' socket without blocking. *NN_POLLOUT*:: Check whether at least one message can be sent to the 'fd' socket without blocking. After the function returns, 'revents' field contains bitwise combination of NN_POLLIN and NN_POLLOUT according to whether the socket is readable or writable. 'timeout' parameter specifies how long (in milliseconds) should the function block if there are no events to report. RETURN VALUE ------------ Upon successful completion, the number of nn_pollfds structures with events signaled is returned. In case of timeout, return value is 0. In case of error, -1 is returned and 'errno' is set the one of the values below. ERRORS ------ *EBADF*:: Some of the provided sockets are invalid. *EINTR*:: The operation was interrupted by delivery of a signal before the message was sent. *ETERM*:: The library is terminating. NOTE ---- nn_poll is a convenience function. You can achieve same behaviour by using NN_RCVFD and NN_SNDFD socket options. However, using the socket options allows for usage that's not possible with nn_poll, such as simultaneous polling for both SP and OS-level sockets, integration of SP sockets with external event loops etc. EXAMPLE ------- ---- struct nn_pollfd pfd [2]; pfd [0].fd = s1; pfd [0].events = NN_POLLIN | NN_POLLOUT; pfd [1].fd = s2; pfd [1].events = NN_POLLIN; rc = nn_poll (pfd, 2, 2000); if (rc == 0) { printf ("Timeout!"); exit (1); } if (rc == -1) { printf ("Error!"); exit (1); } if (pfd [0].revents & NN_POLLIN) { printf ("Message can be received from s1!"); exit (1); } ---- SEE ALSO -------- linknanomsg:nn_socket[3] linknanomsg:nn_getsockopt[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nanomsg.txt0000664000175000017500000000462712623652600017623 0ustar00travistravis00000000000000nanomsg(7) ========== NAME ---- nanomsg - scalability protocols library SYNOPSIS -------- *cc* ['flags'] 'files' *-lnanomsg* ['libraries'] DESCRIPTION ----------- Following functions are exported by nanomsg library: Create an SP socket:: linknanomsg:nn_socket[3] Close an SP socket:: linknanomsg:nn_close[3] Set a socket option:: linknanomsg:nn_setsockopt[3] Retrieve a socket option:: linknanomsg:nn_getsockopt[3] Add a local endpoint to the socket:: linknanomsg:nn_bind[3] Add a remote endpoint to the socket:: linknanomsg:nn_connect[3] Remove an endpoint from the socket:: linknanomsg:nn_shutdown[3] Send a message:: linknanomsg:nn_send[3] Receive a message:: linknanomsg:nn_recv[3] Fine-grained alternative to nn_send:: linknanomsg:nn_sendmsg[3] Fine-grained alternative to nn_recv:: linknanomsg:nn_recvmsg[3] Allocation of messages:: linknanomsg:nn_allocmsg[3] linknanomsg:nn_reallocmsg[3] linknanomsg:nn_freemsg[3] Manipulation of message control data:: linknanomsg:nn_cmsg[3] Multiplexing:: linknanomsg:nn_poll[3] Retrieve the current errno:: linknanomsg:nn_errno[3] Convert an error number into human-readable string:: linknanomsg:nn_strerror[3] Query the names and values of nanomsg symbols:: linknanomsg:nn_symbol[3] Query properties of nanomsg symbols:: linknanomsg:nn_symbol_info[3] Start a device:: linknanomsg:nn_device[3] Notify all sockets about process termination:: linknanomsg:nn_term[3] Environment variables that influence nanomsg work:: linknanomsg:nn_env[7] Following scalability protocols are provided by nanomsg: One-to-one protocol:: linknanomsg:nn_pair[7] Request/reply protocol:: linknanomsg:nn_reqrep[7] Publish/subscribe protocol:: linknanomsg:nn_pubsub[7] Survey protocol:: linknanomsg:nn_survey[7] Pipeline protocol:: linknanomsg:nn_pipeline[7] Message bus protocol:: linknanomsg:nn_bus[7] Following transport mechanisms are provided by nanomsg: In-process transport:: linknanomsg:nn_inproc[7] Inter-process transport:: linknanomsg:nn_ipc[7] TCP transport:: linknanomsg:nn_tcp[7] TCPMUX transport:: linknanomsg:nn_tcpmux[7] WebSocket transport:: linknanomsg:nn_ws[7] Following tools are installed with the library: nanocat:: linknanomsg:nanocat[1] tcpmuxd:: linknanomsg:tcpmuxd[1] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_pair.txt0000664000175000017500000000303412623652600017576 0ustar00travistravis00000000000000nn_pair(7) ========== NAME ---- nn_pair - one-to-one scalability protocol SYNOPSIS -------- *#include * *#include * DESCRIPTION ----------- Pair protocol is the simplest and least scalable scalability protocol. It allows scaling by breaking the application in exactly two pieces. For example, if a monolithic application handles both accounting and agenda of HR department, it can be split into two applications (accounting vs. HR) that are run on two separate servers. These applications can then communicate via PAIR sockets. The downside of this protocol is that its scaling properties are very limited. Splitting the application into two pieces allows to scale the two servers. To add the third server to the cluster, application has to be split once more, say by separating HR functionality into hiring module and salary computation module. Whenever possible, try to use one of the more scalable protocols instead. Socket Types ~~~~~~~~~~~~ NN_PAIR:: Socket for communication with exactly one peer. Each party can send messages at any time. If the peer is not available or send buffer is full subsequent calls to linknanomsg:nn_send[3] will block until it's possible to send the message. Socket Options ~~~~~~~~~~~~~~ No protocol-specific socket options are defined at the moment. SEE ALSO -------- linknanomsg:nn_bus[7] linknanomsg:nn_pubsub[7] linknanomsg:nn_reqrep[7] linknanomsg:nn_pipeline[7] linknanomsg:nn_survey[7] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_reqrep.txt0000664000175000017500000000353512623652600020147 0ustar00travistravis00000000000000nn_reqrep(7) ============ NAME ---- nn_reqrep - request/reply scalability protocol SYNOPSIS -------- *#include * *#include * DESCRIPTION ----------- This protocol is used to distribute the workload among multiple stateless workers. Please note that request/reply applications should be stateless. It's important to include all the information necessary to process the request in the request itself, including information about the sender or the originator of the request if this is necessary to respond to the request. Sender information cannot be retrieved from the underlying socket connection since, firstly, transports like IPC may not have a firm notion of a message origin. Secondly, transports that have some notion may not have a reliable one -- a TCP disconnect may mean a new sender, or it may mean a temporary loss in network connectivity. For this reason, sender information must be included by the application if required. Allocating 6 randomly-generated bytes in the message for the lifetime of the connection is sufficient for most purposes. For longer-lived applications, an UUID is more suitable. Socket Types ~~~~~~~~~~~~ NN_REQ:: Used to implement the client application that sends requests and receives replies. NN_REP:: Used to implement the stateless worker that receives requests and sends replies. Socket Options ~~~~~~~~~~~~~~ NN_REQ_RESEND_IVL:: This option is defined on the full REQ socket. If reply is not received in specified amount of milliseconds, the request will be automatically resent. The type of this option is int. Default value is 60000 (1 minute). SEE ALSO -------- linknanomsg:nn_bus[7] linknanomsg:nn_pubsub[7] linknanomsg:nn_pipeline[7] linknanomsg:nn_survey[7] linknanomsg:nn_pair[7] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_pubsub.txt0000664000175000017500000000525112623652600020146 0ustar00travistravis00000000000000nn_pubsub(7) ============ NAME ---- nn_pubsub - publish/subscribe scalability protocol SYNOPSIS -------- *#include * *#include * DESCRIPTION ----------- Broadcasts messages to multiple destinations. Messages are sent from NN_PUB sockets and will only be received by NN_SUB sockets that have subscribed to the matching 'topic'. Topic is an arbitrary sequence of bytes at the beginning of the message body. The NN_SUB socket will determine whether a message should be delivered to the user by comparing the subscribed topics (using NN_SUB_SUBSCRIBE on a full SUB socket) to the bytes initial bytes in the incomming message, up to the size of the topic. ---- nn_setsockopt (s, NN_SUB, NN_SUB_SUBSCRIBE, "Hello", 5); ---- Will match any message with intial 5 bytes being "Hello", for example, message "Hello, World!" will match. Topic with zero length matches any message. If the socket is subscribed to multiple topics, message matching any of them will be delivered to the user. Since the filtering is performed on the Subscriber side, all the messages from Publisher will be sent over the transport layer. The entire message, including the topic, is delivered to the user. Socket Types ~~~~~~~~~~~~ NN_PUB:: This socket is used to distribute messages to multiple destinations. Receive operation is not defined. NN_SUB:: Receives messages from the publisher. Only messages that the socket is subscribed to are received. When the socket is created there are no subscriptions and thus no messages will be received. Send operation is not defined on this socket. Socket Options ~~~~~~~~~~~~~~ NN_SUB_SUBSCRIBE:: Defined on full SUB socket. Subscribes for a particular topic. Type of the option is string. A single NN_SUB socket can handle multiple subscriptions. NN_SUB_UNSUBSCRIBE:: Defined on full SUB socket. Unsubscribes from a particular topic. Type of the option is string. EXAMPLE ~~~~~~~ ---- int pub = nn_socket (AF_SP, NN_PUB); int sub = nn_socket (AF_SP, NN_SUB); int nbytes; void *buf = NULL; nn_setsockopt (sub, NN_SUB, NN_SUB_SUBSCRIBE, "foo", 3); nn_setsockopt (sub, NN_SUB, NN_SUB_SUBSCRIBE, "bar", 3); nbytes = nn_send (pub, "foo|Hello!", 10); assert(nbytes == 10); nbytes = nn_recv (sub, &buf, NN_MSG, 0); assert (nbytes == 10); nn_freemsg (buf); nbytes = nn_send (pub, "baz|World!", 10); /* Message is not delivered because if matches no subscription. */ nbytes = nn_recv(sub, &buf, NN_MSG, 0); ---- SEE ALSO -------- linknanomsg:nn_bus[7] linknanomsg:nn_reqrep[7] linknanomsg:nn_pipeline[7] linknanomsg:nn_survey[7] linknanomsg:nn_pair[7] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_survey.txt0000664000175000017500000000244412623652600020204 0ustar00travistravis00000000000000nn_survey(7) ============ NAME ---- nn_survey - survey scalability protocol SYNOPSIS -------- *#include * *#include * DESCRIPTION ----------- Allows to broadcast a survey to multiple locations and gather the responses. Socket Types ~~~~~~~~~~~~ NN_SURVEYOR:: Used to send the survey. The survey is delivered to all the connected respondents. Once the query is sent, the socket can be used to receive the responses. When the survey deadline expires, receive will return ETIMEDOUT error. NN_RESPONDENT:: Use to respond to the survey. Survey is received using receive function, response is sent using send function. This socket can be connected to at most one peer. Socket Options ~~~~~~~~~~~~~~ NN_SURVEYOR_DEADLINE:: Specifies how long to wait for responses to the survey. Once the deadline expires, receive function will return ETIMEDOUT error and all subsequent responses to the survey will be silently dropped. The deadline is measured in milliseconds. Option type is int. Default value is 1000 (1 second). SEE ALSO -------- linknanomsg:nn_bus[7] linknanomsg:nn_pubsub[7] linknanomsg:nn_reqrep[7] linknanomsg:nn_pipeline[7] linknanomsg:nn_pair[7] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_pipeline.txt0000664000175000017500000000173412623652600020455 0ustar00travistravis00000000000000nn_pipeline(7) ============== NAME ---- nn_pipeline - scalability protocol for passing tasks through a series of processing steps SYNOPSIS -------- *#include * *#include * DESCRIPTION ----------- Fair queues messages from the previous processing step and load balances them among instances of the next processing step. Socket Types ~~~~~~~~~~~~ NN_PUSH:: This socket is used to send messages to a cluster of load-balanced nodes. Receive operation is not implemented on this socket type. NN_PULL:: This socket is used to receive a message from a cluster of nodes. Send operation is not implemented on this socket type. Socket Options ~~~~~~~~~~~~~~ No protocol-specific socket options are defined at the moment. SEE ALSO -------- linknanomsg:nn_bus[7] linknanomsg:nn_pubsub[7] linknanomsg:nn_reqrep[7] linknanomsg:nn_survey[7] linknanomsg:nn_pair[7] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_bus.txt0000664000175000017500000000227712623652600017444 0ustar00travistravis00000000000000nn_bus(7) ========= NAME ---- nn_bus - message bus scalability protocol SYNOPSIS -------- *#include * *#include * DESCRIPTION ----------- Broadcasts messages from any node to all other nodes in the topology. The socket should never receives messages that it sent itself. This pattern scales only to local level (within a single machine or within a single LAN). Trying to scale it further can result in overloading individual nodes with messages. WARNING: For bus topology to function correctly, user is responsible for ensuring that path from each node to any other node exists within the topology. Raw (AF_SP_RAW) BUS socket never sends the message to the peer it was received from. Socket Types ~~~~~~~~~~~~ NN_BUS:: Sent messages are distributed to all nodes in the topology. Incoming messages from all other nodes in the topology are fair-queued in the socket. Socket Options ~~~~~~~~~~~~~~ There are no options defined at the moment. SEE ALSO -------- linknanomsg:nn_pubsub[7] linknanomsg:nn_reqrep[7] linknanomsg:nn_pipeline[7] linknanomsg:nn_survey[7] linknanomsg:nn_pair[7] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_inproc.txt0000664000175000017500000000314412623652600020137 0ustar00travistravis00000000000000nn_inproc(7) ============ NAME ---- nn_inproc - in-process transport mechanism SYNOPSIS -------- *#include * *#include * DESCRIPTION ----------- In-process transport allows to send messages between threads or modules inside a process. In-process address is an arbitrary case-sensitive string preceded by 'inproc://' protocol specifier. All in-process addresses are visible from any module within the process. They are not visible from outside of the process. The nature of in-process transport makes it easy to pass pointers between threads instead of actual data. This is, however, considered a bad application design and violates the scalable share-nothing architecture. If you do pass pointers among threads, synchronising thread access to shared data becomes your responsibility. Such design also prevents moving the thread into different process or machine once the need arises. As a rule of the thumb, don't pass pointers among threads unless you know what you are doing. The overall buffer size for an inproc connection is determined by NN_RCVBUF socket option on the receiving end of the connection. NN_SNDBUF socket option is ignored. In addition to the buffer, one message of arbitrary size will fit into the buffer. That way, even messages larger than the buffer can be transfered via inproc connection. EXAMPLE ------- ---- nn_bind (s1, "inproc://test"); nn_connect (s2, "inproc://test); ---- SEE ALSO -------- linknanomsg:nn_ipc[7] linknanomsg:nn_tcp[7] linknanomsg:nn_bind[3] linknanomsg:nn_connect[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_ipc.txt0000664000175000017500000000232212623652600017415 0ustar00travistravis00000000000000nn_ipc(7) ========= NAME ---- nn_ipc - inter-process transport mechanism SYNOPSIS -------- *#include * *#include * DESCRIPTION ----------- Inter-process transport allows for sending messages between processes within a single box. The implementation uses native IPC mechanism provided by the local operating system and the IPC addresses are thus OS-specific. On POSIX-compliant systems, UNIX domain sockets are used and IPC addresses are file references. Note that both relative (ipc://test.ipc) and absolute (ipc:///tmp/test.ipc) paths may be used. Also note that access rights on the IPC files must be set in such a way that the appropriate applications can actually use them. On Windows, named pipes are used for IPC. IPC address is an arbitrary case-insensitive string containing any character except for backslash. Internally, address ipc://test means that named pipe \\.\pipe\test will be used. EXAMPLE ------- ---- nn_bind (s1, "ipc:///tmp/test.ipc"); nn_connect (s2, "ipc:///tmp/test.ipc"); ---- SEE ALSO -------- linknanomsg:nn_inproc[7] linknanomsg:nn_tcp[7] linknanomsg:nn_bind[3] linknanomsg:nn_connect[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_tcp.txt0000664000175000017500000000425512623652600017437 0ustar00travistravis00000000000000nn_tcp(7) ========= NAME ---- nn_tcp - TCP transport mechanism SYNOPSIS -------- *#include * *#include * DESCRIPTION ----------- TCP transport allows for passing message over the network using simple reliable one-to-one connections. TCP is the most widely used transport protocol, it is virtually ubiquitous and thus the transport of choice for communication over the network. When binding a TCP socket address of the form tcp://interface:port should be used. Port is the TCP port number to use. Interface is one of the following (optionally placed within square brackets): * Asterisk character (*) meaning all local network interfaces. * IPv4 address of a local network interface in numeric form (192.168.0.111). * IPv6 address of a local network interface in numeric form (::1). When connecting a TCP socket address of the form tcp://interface;address:port should be used. Port is the TCP port number to use. Interface is optional and specifies which local network interface to use. If not specified, OS will select an appropriate interface itself. If specified it can be one of the following (optionally placed within square brackets): * IPv4 address of a local network interface in numeric form (192.168.0.111). * IPv6 address of a local network interface in numeric form (::1). Finally, address specifies the remote address to connect to. It can be one of the following (optionally placed within square brackets): * IPv4 address of a remote network interface in numeric form (192.168.0.111). * IPv6 address of a remote network interface in numeric form (::1). * The DNS name of the remote box. Socket Options ~~~~~~~~~~~~~~ NN_TCP_NODELAY:: This option, when set to 1, disables Nagle's algorithm. It also disables delaying of TCP acknowledgments. Using this option improves latency at the expense of throughput. Type of this option is int. Default value is 0. EXAMPLE ------- ---- nn_bind (s1, "tcp://*:5555"); nn_connect (s2, "tcp://myserver:5555"); ---- SEE ALSO -------- linknanomsg:nn_inproc[7] linknanomsg:nn_ipc[7] linknanomsg:nn_bind[3] linknanomsg:nn_connect[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_tcpmux.txt0000664000175000017500000000324412623652600020166 0ustar00travistravis00000000000000nn_tcpmux(7) ============ NAME ---- nn_tcpmux - TCPMUX transport mechanism SYNOPSIS -------- *#include * *#include * DESCRIPTION ----------- THIS IS AN EXPERIMENTAL FEATURE. DO NOT USE. THE FUNCTIONALITY IS SUBJECT TO CHANGE WITHOUT PRIOR NOTICE. TCPMUX transport is basically the same as TCP transport (see linknanomsg:nn_tcp[7]) except that it allows to specify service names along with IP addresses and TCP ports. What it means in practice is that many applications on the same box can share the same TCP port. When connecting and binding use the same connection string syntax as with TCP transport, except that the initial protocol specification should be 'tcpmux://' instead of 'tcp://' and that the connection string should end with a slash and a service name: ---- nn_connect (s, "tcpmux://192.168.0.1:5555/foo"); ---- When binding to a TCPMUX endpoint, linknanomsg:nn_tcpmuxd[1] daemon must be running on the box and specified port. There is no such requirement when connecting to a TCPMUX endpoint. Socket Options ~~~~~~~~~~~~~~ NN_TCPMUX_NODELAY:: This option, when set to 1, disables Nagle's algorithm. It also disables delaying of TCP acknowledgments. Using this option improves latency at the expense of throughput. Type of this option is int. Default value is 0. EXAMPLE ------- ---- nn_bind (s1, "tcpmux://*:5555/foo"); nn_connect (s2, "tcpmux://server1.example.org:5555/foo"); ---- SEE ALSO -------- linknanomsg:nn_tcpmuxd[1] linknanomsg:nn_tcp[7] linknanomsg:nn_inproc[7] linknanomsg:nn_ipc[7] linknanomsg:nn_bind[3] linknanomsg:nn_connect[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik nanomsg-0.8-beta/doc/nn_ws.txt0000664000175000017500000000542112623652600017276 0ustar00travistravis00000000000000nn_ws(7) ======== NAME ---- nn_ws - WebSocket transport mechanism SYNOPSIS -------- *#include * *#include * DESCRIPTION ----------- THIS IS AN EXPERIMENTAL FEATURE. DO NOT USE. THE FUNCTIONALITY IS SUBJECT TO CHANGE WITHOUT PRIOR NOTICE. When calling either `nn_bind()` or `nn_connect()`, omitting the port defaults to the RFC 6455 default port 80 for HTTP. Example: ws://127.0.0.1 is equivalent to ws://127.0.0.1:80 URI limitations ~~~~~~~~~~~~~~~ When calling `nn_connect()`, the URI may also optionally include the path to a resource and/or query parameters. .Path and query parameters ========================== s1 = nn_socket (AF_SP, NN_PAIR); nn_connect (s1, "ws://example.com/path?query=value"); ========================== This implementation includes the full path and any query parameters in the HTTP handshake when establishing connections with `nn_connect()`. This information is not available via the nanomsg API afterwards, however. Likewise, this implementation does not examine or use either any path or query parameters that may be supplied to `nn_bind()`, as it only binds to the TCP port. This implementation acts as a limited HTTP server that offers SP over WebSocket at all URIs for the given TCP address. Applications should not however depends on this behavior; intervening infrastructure may proxy, filter or route based on URI, and other implementations of the SP over WebSocket protocol may offer other HTTP services at the same TCP port, utilizing the path, query parameters, or both to determine the service to be used. Socket Options ~~~~~~~~~~~~~~ NN_WS_MSG_TYPE:: This option may be set to NN_WS_MSG_TYPE_TEXT or NN_WS_MSG_TYPE_BINARY. The value of this determines whether data messages are sent as WebSocket text frames, or binary frames, per RFC 6455. Text frames should contain only valid UTF-8 text in their payload, or they will be rejected. Binary frames may contain any data. Not all WebSocket implementations support binary frames. The default is to send binary frames. + This option may also be specified as control data when when sending a message with `nn_sendmsg()`. TODO: NN_TCP_NODELAY:: This option, when set to 1, disables Nagle's algorithm. It also disables delaying of TCP acknowledgments. Using this option improves latency at the expense of throughput. Type of this option is int. Default value is 0. EXAMPLE ------- ---- nn_bind (s1, "ws://*:5555"); nn_connect (s2, "ws://myserver:5555"); ---- SEE ALSO -------- linknanomsg:nn_tcp[7] linknanomsg:nn_inproc[7] linknanomsg:nn_ipc[7] linknanomsg:nn_bind[3] linknanomsg:nn_connect[3] linknanomsg:nanomsg[7] AUTHORS ------- Martin Sustrik Jack R. Dunaway Garrett D'Amore nanomsg-0.8-beta/doc/nn_env.txt0000664000175000017500000000426012623652600017435 0ustar00travistravis00000000000000nn_env(7) ========== NAME ---- nn_env - nanomsg environment variables SYNOPSIS -------- Environment variables that influence the way nanomsg works DESCRIPTION ----------- *This functionality is experimental and a subject to change at any time* Following environment variables are used to turn on some debugging for any nanomsg application. Please, do not try to parse output and do not build business logic based on it. NN_PRINT_ERRORS:: If set to non-empty string nanomsg will print errors to stderr. Some errors will be resolved by nanomsg itself (e.g. if nanomsg can't establish connection it will retry again in a moment). Some depend on the environment (e.g. port that is bound by another process need to be released). In any case nanomsg will not repeat the error message until error is clear and appear again (e.g. connection established then broken again). NN_PRINT_STATISTICS:: If set to non-empty string nanomsg will print some statistics to stderr. That's statistics is intended for debugging purposes only. NN_STATISTICS_SOCKET:: The nanomsg address to send statistics to. Nanomsg opens NN_PUB socket and sends statistics there. The data is sent using ESTP protocol. NOTES ----- The output of both debugging facilities (NN_PRINT_ERRORS, NN_PRINT_STATISTICS) is intended for reading by human and a subject for change at any time (even after 1.0 release). The NN_STATISTICS_SOCKET facility is intended to use by system administrators to debug network and application issues. The ESTP format is stable. But the nanomsg support of it is experimental and is subject to change or removal until 1.0 release. Anyway, there is *no excuse* for making application logic based on the data described here. And by application logic we mean any of the following: * Load balancing * Failover * Routing requests * Executing nn_connect/nn_bind There are other ways for load-balancing and failover in nanomsg. If you feel you can't do something, consider ask on the mailing list first. SEE ALSO -------- linknanomsg:nanomsg[7] http://github.com/estp http://github.com/estp/estp/blob/master/specification.rst AUTHORS ------- Paul Colomiets nanomsg-0.8-beta/m4/0000775000175000017500000000000012623652617015172 5ustar00travistravis00000000000000nanomsg-0.8-beta/m4/ax_pthread.m40000664000175000017500000003270312623652600017550 0ustar00travistravis00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_pthread.html # =========================================================================== # # SYNOPSIS # # AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) # # DESCRIPTION # # This macro figures out how to build C programs using POSIX threads. It # sets the PTHREAD_LIBS output variable to the threads library and linker # flags, and the PTHREAD_CFLAGS output variable to any special C compiler # flags that are needed. (The user can also force certain compiler # flags/libs to be tested by setting these environment variables.) # # Also sets PTHREAD_CC to any special C compiler that is needed for # multi-threaded programs (defaults to the value of CC otherwise). (This # is necessary on AIX to use the special cc_r compiler alias.) # # NOTE: You are assumed to not only compile your program with these flags, # but also link it with them as well. e.g. you should link with # $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS # # If you are only building threads programs, you may wish to use these # variables in your default LIBS, CFLAGS, and CC: # # LIBS="$PTHREAD_LIBS $LIBS" # CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # CC="$PTHREAD_CC" # # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant # has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name # (e.g. PTHREAD_CREATE_UNDETACHED on AIX). # # Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the # PTHREAD_PRIO_INHERIT symbol is defined when compiling with # PTHREAD_CFLAGS. # # ACTION-IF-FOUND is a list of shell commands to run if a threads library # is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it # is not found. If ACTION-IF-FOUND is not specified, the default action # will define HAVE_PTHREAD. # # Please let the authors know if this macro fails on any platform, or if # you have any other suggestions or comments. This macro was based on work # by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help # from M. Frigo), as well as ac_pthread and hb_pthread macros posted by # Alejandro Forero Cuervo to the autoconf macro repository. We are also # grateful for the helpful feedback of numerous users. # # Updated for Autoconf 2.68 by Daniel Richard G. # # LICENSE # # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2011 Daniel Richard G. # # This program 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 3 of the License, or (at your # option) any later version. # # This program 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 this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 21 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AC_DEFUN([AX_PTHREAD], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_LANG_PUSH([C]) ax_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes]) AC_MSG_RESULT([$ax_pthread_ok]) if test x"$ax_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case ${host_os} in solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" ;; darwin*) ax_pthread_flags="none -pthread $ax_pthread_flags" ;; esac # Clang doesn't consider unrecognized options an error unless we specify # -Werror. We throw in some extra Clang-specific options to ensure that # this doesn't happen for GCC, which also accepts -Werror. AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags]) save_CFLAGS="$CFLAGS" ax_pthread_extra_flags="-Werror" CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])], [AC_MSG_RESULT([yes])], [ax_pthread_extra_flags= AC_MSG_RESULT([no])]) CFLAGS="$save_CFLAGS" if test x"$ax_pthread_ok" = xno; then for flag in $ax_pthread_flags; do case $flag in none) AC_MSG_CHECKING([whether pthreads work without any flags]) ;; -*) AC_MSG_CHECKING([whether pthreads work with $flag]) PTHREAD_CFLAGS="$flag" ;; pthread-config) AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) if test x"$ax_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) AC_MSG_CHECKING([for the pthreads library -l$flag]) PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include static void routine(void *a) { a = 0; } static void *start_routine(void *a) { return a; }], [pthread_t th; pthread_attr_t attr; pthread_create(&th, 0, start_routine, 0); pthread_join(th, 0); pthread_attr_init(&attr); pthread_cleanup_push(routine, 0); pthread_cleanup_pop(0) /* ; */])], [ax_pthread_ok=yes], []) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" AC_MSG_RESULT([$ax_pthread_ok]) if test "x$ax_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$ax_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. AC_MSG_CHECKING([for joinable pthread attribute]) attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], [int attr = $attr; return attr /* ; */])], [attr_name=$attr; break], []) done AC_MSG_RESULT([$attr_name]) if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name], [Define to necessary symbol if this constant uses a non-standard name on your system.]) fi AC_MSG_CHECKING([if more special flags are required for pthreads]) flag=no case ${host_os} in aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; osf* | hpux*) flag="-D_REENTRANT";; solaris*) if test "$GCC" = "yes"; then flag="-D_REENTRANT" else # TODO: What about Clang on Solaris? flag="-mt -D_REENTRANT" fi ;; esac AC_MSG_RESULT([$flag]) if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], [ax_cv_PTHREAD_PRIO_INHERIT], [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[int i = PTHREAD_PRIO_INHERIT;]])], [ax_cv_PTHREAD_PRIO_INHERIT=yes], [ax_cv_PTHREAD_PRIO_INHERIT=no]) ]) AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"], [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])]) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: compile with *_r variant if test "x$GCC" != xyes; then case $host_os in aix*) AS_CASE(["x/$CC"], [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], [#handle absolute path differently from PATH based program lookup AS_CASE(["x$CC"], [x/*], [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) ;; esac fi fi test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" AC_SUBST([PTHREAD_LIBS]) AC_SUBST([PTHREAD_CFLAGS]) AC_SUBST([PTHREAD_CC]) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$ax_pthread_ok" = xyes; then ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) : else ax_pthread_ok=no $2 fi AC_LANG_POP ])dnl AX_PTHREAD nanomsg-0.8-beta/m4/dolt.m40000664000175000017500000001255512623652600016376 0ustar00travistravis00000000000000dnl dolt, a replacement for libtool dnl Copyright © 2007-2010 Josh Triplett dnl Copying and distribution of this file, with or without modification, dnl are permitted in any medium without royalty provided the copyright dnl notice and this notice are preserved. dnl dnl To use dolt, invoke the DOLT macro immediately after the libtool macros. dnl Optionally, copy this file into acinclude.m4, to avoid the need to have it dnl installed when running autoconf on your project. AC_DEFUN([DOLT], [ AC_REQUIRE([AC_CANONICAL_HOST]) # dolt, a replacement for libtool # Josh Triplett AC_PATH_PROG([DOLT_BASH], [bash]) AC_MSG_CHECKING([if dolt supports this host]) dolt_supported=yes AS_IF([test x$DOLT_BASH = x], [dolt_supported=no]) AS_IF([test x$GCC != xyes], [dolt_supported=no]) AS_CASE([$host], [*-*-linux*|*-*-freebsd*], [pic_options='-fPIC'], [*-apple-darwin*], [pic_options='-fno-common'], [*mingw*|*nacl*], [pic_options=''] [*], [dolt_supported=no] ) AS_IF([test x$dolt_supported = xno], [ AC_MSG_RESULT([no, falling back to libtool]) LTCOMPILE='$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(COMPILE)' LTCXXCOMPILE='$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXXCOMPILE)' m4_pattern_allow([AM_V_lt]) ], [ AC_MSG_RESULT([yes, replacing libtool]) dnl Start writing out doltcompile. cat <<__DOLTCOMPILE__EOF__ >doltcompile #!$DOLT_BASH __DOLTCOMPILE__EOF__ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile args=("$[]@") for ((arg=0; arg<${#args@<:@@@:>@}; arg++)) ; do if test x"${args@<:@$arg@:>@}" = x-o ; then objarg=$((arg+1)) break fi done if test x$objarg = x ; then echo 'Error: no -o on compiler command line' 1>&2 exit 1 fi lo="${args@<:@$objarg@:>@}" obj="${lo%.lo}" if test x"$lo" = x"$obj" ; then echo "Error: libtool object file name \"$lo\" does not end in .lo" 1>&2 exit 1 fi objbase="${obj##*/}" __DOLTCOMPILE__EOF__ dnl Write out shared compilation code. if test x$enable_shared = xyes; then cat <<'__DOLTCOMPILE__EOF__' >>doltcompile libobjdir="${obj%$objbase}.libs" if test ! -d "$libobjdir" ; then mkdir_out="$(mkdir "$libobjdir" 2>&1)" mkdir_ret=$? if test "$mkdir_ret" -ne 0 && test ! -d "$libobjdir" ; then echo "$mkdir_out" 1>&2 exit $mkdir_ret fi fi pic_object="$libobjdir/$objbase.o" args@<:@$objarg@:>@="$pic_object" __DOLTCOMPILE__EOF__ cat <<__DOLTCOMPILE__EOF__ >>doltcompile "\${args@<:@@@:>@}" $pic_options -DPIC || exit \$? __DOLTCOMPILE__EOF__ fi dnl Write out static compilation code. dnl Avoid duplicate compiler output if also building shared objects. if test x$enable_static = xyes; then cat <<'__DOLTCOMPILE__EOF__' >>doltcompile non_pic_object="$obj.o" args@<:@$objarg@:>@="$non_pic_object" __DOLTCOMPILE__EOF__ if test x$enable_shared = xyes; then cat <<'__DOLTCOMPILE__EOF__' >>doltcompile "${args@<:@@@:>@}" >/dev/null 2>&1 || exit $? __DOLTCOMPILE__EOF__ else cat <<'__DOLTCOMPILE__EOF__' >>doltcompile "${args@<:@@@:>@}" || exit $? __DOLTCOMPILE__EOF__ fi fi dnl Write out the code to write the .lo file. dnl The second line of the .lo file must match "^# Generated by .*libtool" cat <<'__DOLTCOMPILE__EOF__' >>doltcompile { echo "# $lo - a libtool object file" echo "# Generated by doltcompile, not libtool" __DOLTCOMPILE__EOF__ if test x$enable_shared = xyes; then cat <<'__DOLTCOMPILE__EOF__' >>doltcompile echo "pic_object='.libs/${objbase}.o'" __DOLTCOMPILE__EOF__ else cat <<'__DOLTCOMPILE__EOF__' >>doltcompile echo pic_object=none __DOLTCOMPILE__EOF__ fi if test x$enable_static = xyes; then cat <<'__DOLTCOMPILE__EOF__' >>doltcompile echo "non_pic_object='${objbase}.o'" __DOLTCOMPILE__EOF__ else cat <<'__DOLTCOMPILE__EOF__' >>doltcompile echo non_pic_object=none __DOLTCOMPILE__EOF__ fi cat <<'__DOLTCOMPILE__EOF__' >>doltcompile } > "$lo" __DOLTCOMPILE__EOF__ dnl Done writing out doltcompile; substitute it for libtool compilation. chmod +x doltcompile LTCOMPILE='$(top_builddir)/doltcompile $(COMPILE)' LTCXXCOMPILE='$(top_builddir)/doltcompile $(CXXCOMPILE)' dnl automake ignores LTCOMPILE and LTCXXCOMPILE when it has separate CFLAGS for dnl a target, so write out a libtool wrapper to handle that case. dnl Note that doltlibtool does not handle inferred tags or option arguments dnl without '=', because automake does not use them. cat <<__DOLTLIBTOOL__EOF__ > doltlibtool #!$DOLT_BASH __DOLTLIBTOOL__EOF__ cat <<'__DOLTLIBTOOL__EOF__' >>doltlibtool top_builddir_slash="${0%%doltlibtool}" : ${top_builddir_slash:=./} args=() modeok=false tagok=false for arg in "$[]@"; do case "$arg" in --mode=compile) modeok=true ;; --tag=CC|--tag=CXX) tagok=true ;; --silent|--quiet) ;; *) args@<:@${#args[@]}@:>@="$arg" ;; esac done if $modeok && $tagok ; then . ${top_builddir_slash}doltcompile "${args@<:@@@:>@}" else exec ${top_builddir_slash}libtool "$[]@" fi __DOLTLIBTOOL__EOF__ dnl Done writing out doltlibtool; substitute it for libtool. chmod +x doltlibtool LIBTOOL='$(top_builddir)/doltlibtool' DOLT_CLEANFILES="doltlibtool doltcompile" AC_SUBST(DOLT_CLEANFILES) ]) AC_SUBST(LTCOMPILE) AC_SUBST(LTCXXCOMPILE) # end dolt ]) nanomsg-0.8-beta/m4/libtool.m40000644000175000017500000106043412623652607017105 0ustar00travistravis00000000000000# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 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, 2009, 2010, 2011 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 57 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_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl 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 _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) 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 "$cc_temp" | $SED "s%.*/%%; 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 AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl 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_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])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 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 # 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_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify 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' ]) # _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 ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # 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], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _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 "$][$1" | $SED "$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 "$" | $SED "$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' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$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 \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # `#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test $lt_write_fail = 0 && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_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]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false 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) 2011 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. 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) ])# 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 '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_REPLACE_SHELLFNS 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)], [Go], [_LT_LANG(GO)], [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 m4_ifndef([AC_PROG_GO], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _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([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) 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)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) 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], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _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 there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 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" ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) 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" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # 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 if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _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=func_echo_all _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([TAGNAME]) # ---------------------------------- # 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. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`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 "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script which will find a shell with a builtin # printf (which we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case "$ECHO" in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified).], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([${with_sysroot}]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and in which our libraries should be installed.])]) # _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 '$LINENO' "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 ;; *-*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*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) 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_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR 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 \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _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_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _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:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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 "$_lt_linker_boilerplate" | $SED '/^$/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; ;; mint*) # On MiNT this can take a long time and run out of memory. 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 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; 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"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$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 $LINENO "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 /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 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; else puts (dlerror ()); } /* 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:$LINENO: $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:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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 m4_require([_LT_CHECK_SHELL_FEATURES])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 case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # 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 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # 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; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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=`func_echo_all "$lib" | $SED '\''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 # correct to gnu/linux during the next big refactor 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,$cc_basename in yes,*) # gcc 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}' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; 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 dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. 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 # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # 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' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # 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 # correct to gnu/linux during the next big refactor 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 ;; 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[[23]].*) 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 # correct to gnu/linux during the next big refactor 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 ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" 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=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' 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' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor 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 AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no 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], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # 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;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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _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 m4_require([_LT_PROG_ECHO_BACKSLASH])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 # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' 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 ;; haiku*) 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])(-bit)?( [LM]SB)? 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 glibc/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_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi 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_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob 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. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi 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:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $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:$LINENO: 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_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-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 case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _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([AC_PROG_AWK])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};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /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 lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # 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 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #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. */ LT@&t@_DLSYM_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_globsym_save_LIBS=$LIBS lt_globsym_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_globsym_save_LIBS CFLAGS=$lt_globsym_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 # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' 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_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _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)= 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)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $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 ;; 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). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; 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* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _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* | sunCC*) # 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' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; 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 case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; 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' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # 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* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _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\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # 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)='' ;; *Sun\ F* | *Sun*Fortran*) _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 ' ;; *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,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; 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* | sunf77* | sunf90* | sunf95*) _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_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # 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]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # 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_PATH_MANIFEST_TOOL])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' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] 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 # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". 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") || (\$ 2 == "W")) && ([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*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; linux* | k*bsd*-gnu | 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 ], [ 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_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 | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = 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.19, 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 install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _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(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _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/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] 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 ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; 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=' $pic_flag' 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; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # 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; func_echo_all \"$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]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; 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; func_echo_all \"$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* | bgf* | bgxlf* | mpixlf*) # 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)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_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 $linker_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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $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 # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". 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") || (\$ 2 == "W")) && ([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([$1]) _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 func_echo_all "${wl}${allow_undefined_flag}"; 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([$1]) _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' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _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. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # 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 $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _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' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _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 `func_echo_all "$deplibs" | $SED '\''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(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; 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 ;; # 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 $pic_flag -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 $pic_flag ${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 && test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${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_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 && test "$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 $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${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' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS="$save_LDFLAGS"]) if test "$lt_cv_irix_exported_symbol" = yes; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -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" && func_echo_all "-set_version $verstring"` -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" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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" && func_echo_all "-set_version $verstring"` -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} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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" && func_echo_all "-set_version $verstring"` -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 "-set_version $verstring"` -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 $pic_flag ${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 $pic_flag ${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_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$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_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_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* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_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_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([], [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([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _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 ## 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... 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_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], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl 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 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_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(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_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_CFLAGS=$CFLAGS 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++"} CFLAGS=$CXXFLAGS 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 $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -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 -v "^Configured with:" | $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([$1]) _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 func_echo_all "${wl}${allow_undefined_flag}"; 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([$1]) _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' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _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*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # 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 _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # 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 $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _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(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _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 ;; esac ;; 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 ;; freebsd2.*) # 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*) ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; 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; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${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; func_echo_all "$list"' ;; *) 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 $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${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" && func_echo_all "-set_version $verstring"` -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 $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -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; func_echo_all "$list"' _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 | sort | $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 | sort | $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 | sort | $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 | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above 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; func_echo_all \"$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=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # 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; func_echo_all \"$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='func_echo_all' # 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=func_echo_all 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" && func_echo_all "${wl}-set_version $verstring"` -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" && func_echo_all "-set_version $verstring"` -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 "-set_version $verstring"` -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=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) 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" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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 -v "^Configured with:" | $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* | sunCC*) # 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='func_echo_all' # 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 $pic_flag -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 $pic_flag -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 -v "^Configured with:" | $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 -v "^Configured with:" | $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(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _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 CFLAGS=$lt_save_CFLAGS 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_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf 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). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _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 AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])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 ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac 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 ${prev}${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 fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} 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 prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$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 CFLAGS=$_lt_libdeps_save_CFLAGS # 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* | sunCC*) # 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_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_LANG_PUSH(Fortran 77) if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi _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_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(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_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 lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS 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" CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _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_LANG_PUSH(Fortran) if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi _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_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(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_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 lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS 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 CFLAGS=$lt_save_CFLAGS 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_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS 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 _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## 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... 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 CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # 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_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # Go 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 _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## 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... 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 CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_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_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= 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 CFLAGS=$lt_save_CFLAGS ])# _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_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # 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_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _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%"$_lt_dummy"}, \ = c,a/b,b/c, \ && 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_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) # ------------------------------------------------------ # In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and # '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. m4_defun([_LT_PROG_FUNCTION_REPLACE], [dnl { sed -e '/^$1 ()$/,/^} # $1 /c\ $1 ()\ {\ m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) } # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: ]) # _LT_PROG_REPLACE_SHELLFNS # ------------------------- # Replace existing portable implementations of several shell functions with # equivalent extended shell implementations where those features are available.. m4_defun([_LT_PROG_REPLACE_SHELLFNS], [if test x"$xsi_shell" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl # 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}"}]) _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl func_split_long_opt_name=${1%%=*} func_split_long_opt_arg=${1#*=}]) _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) fi if test x"$lt_shell_append" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl func_quote_for_eval "${2}" dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) fi ]) # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine which file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS nanomsg-0.8-beta/m4/ltoptions.m40000644000175000017500000003007312623652607017467 0ustar00travistravis00000000000000# Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008, 2009 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 7 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 ## --------------------------------- ## ## Macros to handle LT_INIT 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], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [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@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac], [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], []) ## ----------------- ## ## LTDL_INIT Options ## ## ----------------- ## 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])]) nanomsg-0.8-beta/m4/ltsugar.m40000644000175000017500000001042412623652607017113 0ustar00travistravis00000000000000# 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 ]) nanomsg-0.8-beta/m4/ltversion.m40000644000175000017500000000126212623652607017457 0ustar00travistravis00000000000000# 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. # @configure_input@ # serial 3337 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.2]) m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.2' macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) nanomsg-0.8-beta/m4/lt~obsolete.m40000644000175000017500000001375612623652607020017 0ustar00travistravis00000000000000# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2009 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 5 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_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])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) nanomsg-0.8-beta/perf/0000775000175000017500000000000012623652617015606 5ustar00travistravis00000000000000nanomsg-0.8-beta/perf/inproc_lat.c0000664000175000017500000000661012623652600020077 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "../src/utils/attr.h" #include "../src/utils/err.c" #include "../src/utils/thread.c" #include "../src/utils/sleep.c" #include "../src/utils/stopwatch.c" #include #include #include #include static size_t message_size; static int roundtrip_count; void worker (NN_UNUSED void *arg) { int rc; int s; int i; char *buf; s = nn_socket (AF_SP, NN_PAIR); assert (s != -1); rc = nn_connect (s, "inproc://inproc_lat"); assert (rc >= 0); buf = malloc (message_size); assert (buf); for (i = 0; i != roundtrip_count; i++) { rc = nn_recv (s, buf, message_size, 0); assert (rc == (int)message_size); rc = nn_send (s, buf, message_size, 0); assert (rc == (int)message_size); } free (buf); rc = nn_close (s); assert (rc == 0); } int main (int argc, char *argv []) { int rc; int s; int i; char *buf; struct nn_thread thread; struct nn_stopwatch stopwatch; uint64_t elapsed; double latency; if (argc != 3) { printf ("usage: inproc_lat \n"); return 1; } message_size = atoi (argv [1]); roundtrip_count = atoi (argv [2]); s = nn_socket (AF_SP, NN_PAIR); assert (s != -1); rc = nn_bind (s, "inproc://inproc_lat"); assert (rc >= 0); buf = malloc (message_size); assert (buf); memset (buf, 111, message_size); /* Wait a bit till the worker thread blocks in nn_recv(). */ nn_thread_init (&thread, worker, NULL); nn_sleep (100); nn_stopwatch_init (&stopwatch); for (i = 0; i != roundtrip_count; i++) { rc = nn_send (s, buf, message_size, 0); assert (rc == (int)message_size); rc = nn_recv (s, buf, message_size, 0); assert (rc == (int)message_size); } elapsed = nn_stopwatch_term (&stopwatch); latency = (double) elapsed / (roundtrip_count * 2); printf ("message size: %d [B]\n", (int) message_size); printf ("roundtrip count: %d\n", (int) roundtrip_count); printf ("average latency: %.3f [us]\n", (double) latency); nn_thread_term (&thread); free (buf); rc = nn_close (s); assert (rc == 0); return 0; } nanomsg-0.8-beta/perf/inproc_thr.c0000664000175000017500000000677612623652600020131 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "../src/utils/attr.h" #include "../src/utils/err.c" #include "../src/utils/thread.c" #include "../src/utils/stopwatch.c" #include #include #include #include static size_t message_size; static int message_count; void worker (NN_UNUSED void *arg) { int rc; int s; int i; char *buf; s = nn_socket (AF_SP, NN_PAIR); assert (s != -1); rc = nn_connect (s, "inproc://inproc_thr"); assert (rc >= 0); buf = malloc (message_size); assert (buf); memset (buf, 111, message_size); rc = nn_send (s, NULL, 0, 0); assert (rc == 0); for (i = 0; i != message_count; i++) { rc = nn_send (s, buf, message_size, 0); assert (rc == (int)message_size); } free (buf); rc = nn_close (s); assert (rc == 0); } int main (int argc, char *argv []) { int rc; int s; int i; char *buf; struct nn_thread thread; struct nn_stopwatch stopwatch; uint64_t elapsed; unsigned long throughput; double megabits; if (argc != 3) { printf ("usage: thread_thr \n"); return 1; } message_size = atoi (argv [1]); message_count = atoi (argv [2]); s = nn_socket (AF_SP, NN_PAIR); assert (s != -1); rc = nn_bind (s, "inproc://inproc_thr"); assert (rc >= 0); buf = malloc (message_size); assert (buf); nn_thread_init (&thread, worker, NULL); /* First message is used to start the stopwatch. */ rc = nn_recv (s, buf, message_size, 0); assert (rc == 0); nn_stopwatch_init (&stopwatch); for (i = 0; i != message_count; i++) { rc = nn_recv (s, buf, message_size, 0); assert (rc == (int)message_size); } elapsed = nn_stopwatch_term (&stopwatch); nn_thread_term (&thread); free (buf); rc = nn_close (s); assert (rc == 0); if (elapsed == 0) elapsed = 1; throughput = (unsigned long) ((double) message_count / (double) elapsed * 1000000); megabits = (double) (throughput * message_size * 8) / 1000000; printf ("message size: %d [B]\n", (int) message_size); printf ("message count: %d\n", (int) message_count); printf ("mean throughput: %d [msg/s]\n", (int) throughput); printf ("mean throughput: %.3f [Mb/s]\n", (double) megabits); return 0; } nanomsg-0.8-beta/perf/local_lat.c0000664000175000017500000000427012623652600017677 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/tcp.h" #include "../src/pair.h" #include #include #include #include int main (int argc, char *argv []) { const char *bind_to; size_t sz; int rts; char *buf; int nbytes; int s; int rc; int i; int opt; if (argc != 4) { printf ("usage: local_lat \n"); return 1; } bind_to = argv [1]; sz = atoi (argv [2]); rts = atoi (argv [3]); s = nn_socket (AF_SP, NN_PAIR); assert (s != -1); opt = 1; rc = nn_setsockopt (s, NN_TCP, NN_TCP_NODELAY, &opt, sizeof (opt)); assert (rc == 0); rc = nn_bind (s, bind_to); assert (rc >= 0); buf = malloc (sz); assert (buf); memset (buf, 111, sz); for (i = 0; i != rts; i++) { nbytes = nn_recv (s, buf, sz, 0); assert (nbytes == (int)sz); nbytes = nn_send (s, buf, sz, 0); assert (nbytes == (int)sz); } free (buf); rc = nn_close (s); assert (rc == 0); return 0; } nanomsg-0.8-beta/perf/local_thr.c0000664000175000017500000000502012623652600017706 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include #include #include #include "../src/utils/stopwatch.c" int main (int argc, char *argv []) { const char *bind_to; size_t sz; int count; char *buf; int nbytes; int s; int rc; int i; struct nn_stopwatch sw; uint64_t total; uint64_t thr; double mbs; if (argc != 4) { printf ("usage: local_thr \n"); return 1; } bind_to = argv [1]; sz = atoi (argv [2]); count = atoi (argv [3]); s = nn_socket (AF_SP, NN_PAIR); assert (s != -1); rc = nn_bind (s, bind_to); assert (rc >= 0); buf = malloc (sz); assert (buf); nbytes = nn_recv (s, buf, sz, 0); assert (nbytes == 0); nn_stopwatch_init (&sw); for (i = 0; i != count; i++) { nbytes = nn_recv (s, buf, sz, 0); assert (nbytes == (int)sz); } total = nn_stopwatch_term (&sw); if (total == 0) total = 1; thr = (uint64_t) ((double) count / (double) total * 1000000); mbs = (double) (thr * sz * 8) / 1000000; printf ("message size: %d [B]\n", (int) sz); printf ("message count: %d\n", (int) count); printf ("throughput: %d [msg/s]\n", (int) thr); printf ("throughput: %.3f [Mb/s]\n", (double) mbs); free (buf); rc = nn_close (s); assert (rc == 0); return 0; } nanomsg-0.8-beta/perf/remote_lat.c0000664000175000017500000000506412623652600020102 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/tcp.h" #include "../src/pair.h" #include #include #include #include #include "../src/utils/stopwatch.c" int main (int argc, char *argv []) { const char *connect_to; size_t sz; int rts; char *buf; int nbytes; int s; int rc; int i; int opt; struct nn_stopwatch sw; uint64_t total; double lat; if (argc != 4) { printf ("usage: remote_lat \n"); return 1; } connect_to = argv [1]; sz = atoi (argv [2]); rts = atoi (argv [3]); s = nn_socket (AF_SP, NN_PAIR); assert (s != -1); opt = 1; rc = nn_setsockopt (s, NN_TCP, NN_TCP_NODELAY, &opt, sizeof (opt)); assert (rc == 0); rc = nn_connect (s, connect_to); assert (rc >= 0); buf = malloc (sz); assert (buf); memset (buf, 111, sz); nn_stopwatch_init (&sw); for (i = 0; i != rts; i++) { nbytes = nn_send (s, buf, sz, 0); assert (nbytes == (int)sz); nbytes = nn_recv (s, buf, sz, 0); assert (nbytes == (int)sz); } total = nn_stopwatch_term (&sw); lat = (double) total / (rts * 2); printf ("message size: %d [B]\n", (int) sz); printf ("roundtrip count: %d\n", (int) rts); printf ("average latency: %.3f [us]\n", (double) lat); free (buf); rc = nn_close (s); assert (rc == 0); return 0; } nanomsg-0.8-beta/perf/remote_thr.c0000664000175000017500000000405712623652600020120 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include #include #include #include int main (int argc, char *argv []) { const char *connect_to; size_t sz; int count; char *buf; int nbytes; int s; int rc; int i; if (argc != 4) { printf ("usage: remote_thr \n"); return 1; } connect_to = argv [1]; sz = atoi (argv [2]); count = atoi (argv [3]); s = nn_socket (AF_SP, NN_PAIR); assert (s != -1); rc = nn_connect (s, connect_to); assert (rc >= 0); buf = malloc (sz); assert (buf); memset (buf, 111, sz); nbytes = nn_send (s, buf, 0, 0); assert (nbytes == 0); for (i = 0; i != count; i++) { nbytes = nn_send (s, buf, sz, 0); assert (nbytes == (int)sz); } free (buf); rc = nn_close (s); assert (rc == 0); return 0; } nanomsg-0.8-beta/src/0000775000175000017500000000000012623652617015441 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/aio/0000775000175000017500000000000012623652617016211 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/aio/ctx.h0000664000175000017500000000372512623652600017157 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_CTX_INCLUDED #define NN_CTX_INCLUDED #include "../utils/mutex.h" #include "../utils/queue.h" #include "worker.h" #include "pool.h" #include "fsm.h" /* AIO context for objects using AIO subsystem. */ typedef void (*nn_ctx_onleave) (struct nn_ctx *self); struct nn_ctx { struct nn_mutex sync; struct nn_pool *pool; struct nn_queue events; struct nn_queue eventsto; nn_ctx_onleave onleave; }; void nn_ctx_init (struct nn_ctx *self, struct nn_pool *pool, nn_ctx_onleave onleave); void nn_ctx_term (struct nn_ctx *self); void nn_ctx_enter (struct nn_ctx *self); void nn_ctx_leave (struct nn_ctx *self); struct nn_worker *nn_ctx_choose_worker (struct nn_ctx *self); void nn_ctx_raise (struct nn_ctx *self, struct nn_fsm_event *event); void nn_ctx_raiseto (struct nn_ctx *self, struct nn_fsm_event *event); #endif nanomsg-0.8-beta/src/aio/ctx.c0000664000175000017500000000660412623652600017151 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "ctx.h" #include "../utils/err.h" #include "../utils/cont.h" #include "../utils/fast.h" void nn_ctx_init (struct nn_ctx *self, struct nn_pool *pool, nn_ctx_onleave onleave) { nn_mutex_init (&self->sync); self->pool = pool; nn_queue_init (&self->events); nn_queue_init (&self->eventsto); self->onleave = onleave; } void nn_ctx_term (struct nn_ctx *self) { nn_queue_term (&self->eventsto); nn_queue_term (&self->events); nn_mutex_term (&self->sync); } void nn_ctx_enter (struct nn_ctx *self) { nn_mutex_lock (&self->sync); } void nn_ctx_leave (struct nn_ctx *self) { struct nn_queue_item *item; struct nn_fsm_event *event; struct nn_queue eventsto; /* Process any queued events before leaving the context. */ while (1) { item = nn_queue_pop (&self->events); event = nn_cont (item, struct nn_fsm_event, item); if (!event) break; nn_fsm_event_process (event); } /* Notify the owner that we are leaving the context. */ if (nn_fast (self->onleave != NULL)) self->onleave (self); /* Shortcut in the case there are no external events. */ if (nn_queue_empty (&self->eventsto)) { nn_mutex_unlock (&self->sync); return; } /* Make a copy of the queue of the external events so that it does not get corrupted once we unlock the context. */ eventsto = self->eventsto; nn_queue_init (&self->eventsto); nn_mutex_unlock (&self->sync); /* Process any queued external events. Before processing each event lock the context it belongs to. */ while (1) { item = nn_queue_pop (&eventsto); event = nn_cont (item, struct nn_fsm_event, item); if (!event) break; nn_ctx_enter (event->fsm->ctx); nn_fsm_event_process (event); nn_ctx_leave (event->fsm->ctx); } nn_queue_term (&eventsto); } struct nn_worker *nn_ctx_choose_worker (struct nn_ctx *self) { return nn_pool_choose_worker (self->pool); } void nn_ctx_raise (struct nn_ctx *self, struct nn_fsm_event *event) { nn_queue_push (&self->events, &event->item); } void nn_ctx_raiseto (struct nn_ctx *self, struct nn_fsm_event *event) { nn_queue_push (&self->eventsto, &event->item); } nanomsg-0.8-beta/src/aio/fsm.h0000664000175000017500000001004312623652600017135 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_FSM_INCLUDED #define NN_FSM_INCLUDED #include "../utils/queue.h" /* Base class for state machines. */ struct nn_ctx; struct nn_fsm; struct nn_worker; struct nn_fsm_event { struct nn_fsm *fsm; int src; void *srcptr; int type; struct nn_queue_item item; }; void nn_fsm_event_init (struct nn_fsm_event *self); void nn_fsm_event_term (struct nn_fsm_event *self); int nn_fsm_event_active (struct nn_fsm_event *self); void nn_fsm_event_process (struct nn_fsm_event *self); /* Special source for actions. It's negative not to clash with user-defined sources. */ #define NN_FSM_ACTION -2 /* Actions generated by fsm object. The values are negative not to clash with user-defined actions. */ #define NN_FSM_START -2 #define NN_FSM_STOP -3 /* Virtual function to be implemented by the derived class to handle the incoming events. */ typedef void (*nn_fsm_fn) (struct nn_fsm *self, int src, int type, void *srcptr); struct nn_fsm_owner { int src; struct nn_fsm *fsm; }; struct nn_fsm { nn_fsm_fn fn; nn_fsm_fn shutdown_fn; int state; int src; void *srcptr; struct nn_fsm *owner; struct nn_ctx *ctx; struct nn_fsm_event stopped; }; void nn_fsm_init_root (struct nn_fsm *self, nn_fsm_fn fn, nn_fsm_fn shutdown_fn, struct nn_ctx *ctx); void nn_fsm_init (struct nn_fsm *self, nn_fsm_fn fn, nn_fsm_fn shutdown_fn, int src, void *srcptr, struct nn_fsm *owner); void nn_fsm_term (struct nn_fsm *self); int nn_fsm_isidle (struct nn_fsm *self); void nn_fsm_start (struct nn_fsm *self); void nn_fsm_stop (struct nn_fsm *self); void nn_fsm_stopped (struct nn_fsm *self, int type); void nn_fsm_stopped_noevent (struct nn_fsm *self); /* Replaces current owner of the fsm by the owner speicified by 'owner' parameter. The parameter will hold the old owner afrer the call. */ void nn_fsm_swap_owner (struct nn_fsm *self, struct nn_fsm_owner *owner); struct nn_worker *nn_fsm_choose_worker (struct nn_fsm *self); /* Using this function state machine can trigger an action on itself. */ void nn_fsm_action (struct nn_fsm *self, int type); /* Send event from the state machine to its owner. */ void nn_fsm_raise (struct nn_fsm *self, struct nn_fsm_event *event, int type); /* Send event to the specified state machine. It's caller's responsibility to ensure that the destination state machine will still exist when the event is delivered. NOTE: This function is a hack to make inproc transport work in the most efficient manner. Do not use it outside of inproc transport! */ void nn_fsm_raiseto (struct nn_fsm *self, struct nn_fsm *dst, struct nn_fsm_event *event, int src, int type, void *srcptr); /* This function is very lowlevel action feeding Used in worker threads and timers, shouldn't be used by others use nn_fsm_action/nn_fsm_raise/nn_fsm_raiseto instread*/ void nn_fsm_feed (struct nn_fsm *self, int src, int type, void *srcptr); #endif nanomsg-0.8-beta/src/aio/fsm.c0000664000175000017500000001167312623652600017142 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "fsm.h" #include "ctx.h" #include "../utils/err.h" #include #define NN_FSM_STATE_IDLE 1 #define NN_FSM_STATE_ACTIVE 2 #define NN_FSM_STATE_STOPPING 3 void nn_fsm_event_init (struct nn_fsm_event *self) { self->fsm = NULL; self->src = -1; self->srcptr = NULL; self->type = -1; nn_queue_item_init (&self->item); } void nn_fsm_event_term (struct nn_fsm_event *self) { nn_queue_item_term (&self->item); } int nn_fsm_event_active (struct nn_fsm_event *self) { return nn_queue_item_isinqueue (&self->item); } void nn_fsm_event_process (struct nn_fsm_event *self) { int src; int type; void *srcptr; src = self->src; type = self->type; srcptr = self->srcptr; self->src = -1; self->type = -1; self->srcptr = NULL; nn_fsm_feed (self->fsm, src, type, srcptr); } void nn_fsm_feed (struct nn_fsm *self, int src, int type, void *srcptr) { if (nn_slow (self->state != NN_FSM_STATE_STOPPING)) { self->fn (self, src, type, srcptr); } else { self->shutdown_fn (self, src, type, srcptr); } } void nn_fsm_init_root (struct nn_fsm *self, nn_fsm_fn fn, nn_fsm_fn shutdown_fn, struct nn_ctx *ctx) { self->fn = fn; self->shutdown_fn = shutdown_fn; self->state = NN_FSM_STATE_IDLE; self->src = -1; self->srcptr = NULL; self->owner = NULL; self->ctx = ctx; nn_fsm_event_init (&self->stopped); } void nn_fsm_init (struct nn_fsm *self, nn_fsm_fn fn, nn_fsm_fn shutdown_fn, int src, void *srcptr, struct nn_fsm *owner) { self->fn = fn; self->shutdown_fn = shutdown_fn; self->state = NN_FSM_STATE_IDLE; self->src = src; self->srcptr = srcptr; self->owner = owner; self->ctx = owner->ctx; nn_fsm_event_init (&self->stopped); } void nn_fsm_term (struct nn_fsm *self) { nn_assert (nn_fsm_isidle (self)); nn_fsm_event_term (&self->stopped); } void nn_fsm_start (struct nn_fsm *self) { nn_assert (nn_fsm_isidle (self)); self->fn (self, NN_FSM_ACTION, NN_FSM_START, NULL); self->state = NN_FSM_STATE_ACTIVE; } int nn_fsm_isidle (struct nn_fsm *self) { return self->state == NN_FSM_STATE_IDLE && !nn_fsm_event_active (&self->stopped) ? 1 : 0; } void nn_fsm_stop (struct nn_fsm *self) { /* If stopping of the state machine was already requested, do nothing. */ if (self->state != NN_FSM_STATE_ACTIVE) return; self->state = NN_FSM_STATE_STOPPING; self->shutdown_fn (self, NN_FSM_ACTION, NN_FSM_STOP, NULL); } void nn_fsm_stopped (struct nn_fsm *self, int type) { nn_assert_state (self, NN_FSM_STATE_STOPPING); nn_fsm_raise (self, &self->stopped, type); self->state = NN_FSM_STATE_IDLE; } void nn_fsm_stopped_noevent (struct nn_fsm *self) { nn_assert_state (self, NN_FSM_STATE_STOPPING); self->state = NN_FSM_STATE_IDLE; } void nn_fsm_swap_owner (struct nn_fsm *self, struct nn_fsm_owner *owner) { int oldsrc; struct nn_fsm *oldowner; oldsrc = self->src; oldowner = self->owner; self->src = owner->src; self->owner = owner->fsm; owner->src = oldsrc; owner->fsm = oldowner; } struct nn_worker *nn_fsm_choose_worker (struct nn_fsm *self) { return nn_ctx_choose_worker (self->ctx); } void nn_fsm_action (struct nn_fsm *self, int type) { nn_assert (type > 0); nn_fsm_feed (self, NN_FSM_ACTION, type, NULL); } void nn_fsm_raise (struct nn_fsm *self, struct nn_fsm_event *event, int type) { event->fsm = self->owner; event->src = self->src; event->srcptr = self->srcptr; event->type = type; nn_ctx_raise (self->ctx, event); } void nn_fsm_raiseto (struct nn_fsm *self, struct nn_fsm *dst, struct nn_fsm_event *event, int src, int type, void *srcptr) { event->fsm = dst; event->src = src; event->srcptr = srcptr; event->type = type; nn_ctx_raiseto (self->ctx, event); } nanomsg-0.8-beta/src/aio/poller.h0000664000175000017500000000424112623652600017650 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_POLLER_INCLUDED #define NN_POLLER_INCLUDED #if !defined NN_HAVE_WINDOWS #define NN_POLLER_IN 1 #define NN_POLLER_OUT 2 #define NN_POLLER_ERR 3 #if defined NN_USE_POLL #include "poller_poll.h" #elif defined NN_USE_EPOLL #include "poller_epoll.h" #elif defined NN_USE_KQUEUE #include "poller_kqueue.h" #endif int nn_poller_init (struct nn_poller *self); void nn_poller_term (struct nn_poller *self); void nn_poller_add (struct nn_poller *self, int fd, struct nn_poller_hndl *hndl); void nn_poller_rm (struct nn_poller *self, struct nn_poller_hndl *hndl); void nn_poller_set_in (struct nn_poller *self, struct nn_poller_hndl *hndl); void nn_poller_reset_in (struct nn_poller *self, struct nn_poller_hndl *hndl); void nn_poller_set_out (struct nn_poller *self, struct nn_poller_hndl *hndl); void nn_poller_reset_out (struct nn_poller *self, struct nn_poller_hndl *hndl); int nn_poller_wait (struct nn_poller *self, int timeout); int nn_poller_event (struct nn_poller *self, int *event, struct nn_poller_hndl **hndl); #endif #endif nanomsg-0.8-beta/src/aio/poller.c0000664000175000017500000000254412623652600017647 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "poller.h" #if !defined NN_HAVE_WINDOWS #if defined NN_USE_POLL #include "poller_poll.inc" #elif defined NN_USE_EPOLL #include "poller_epoll.inc" #elif defined NN_USE_KQUEUE #include "poller_kqueue.inc" #endif #endif nanomsg-0.8-beta/src/aio/poller_epoll.h0000664000175000017500000000321312623652600021041 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 #include #include #define NN_POLLER_HAVE_ASYNC_ADD 1 #define NN_POLLER_MAX_EVENTS 32 struct nn_poller_hndl { int fd; uint32_t events; }; struct nn_poller { /* Current pollset. */ int ep; /* Number of events being processed at the moment. */ int nevents; /* Index of the event being processed at the moment. */ int index; /* Events being processed at the moment. */ struct epoll_event events [NN_POLLER_MAX_EVENTS]; }; nanomsg-0.8-beta/src/aio/poller_epoll.inc0000664000175000017500000001442512623652600021372 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../utils/fast.h" #include "../utils/err.h" #include "../utils/closefd.h" #include #include #include int nn_poller_init (struct nn_poller *self) { #ifndef EPOLL_CLOEXEC int rc; #endif #ifdef EPOLL_CLOEXEC self->ep = epoll_create1 (EPOLL_CLOEXEC); #else /* Size parameter is unused, we can safely set it to 1. */ self->ep = epoll_create (1); rc = fcntl (self->ep, F_SETFD, FD_CLOEXEC); errno_assert (rc != -1); #endif if (self->ep == -1) { if (errno == ENFILE || errno == EMFILE) return -EMFILE; errno_assert (0); } self->nevents = 0; self->index = 0; return 0; } void nn_poller_term (struct nn_poller *self) { nn_closefd (self->ep); } void nn_poller_add (struct nn_poller *self, int fd, struct nn_poller_hndl *hndl) { int rc; struct epoll_event ev; /* Initialise the handle and add the file descriptor to the pollset. */ hndl->fd = fd; hndl->events = 0; memset (&ev, 0, sizeof (ev)); ev.events = 0; ev.data.ptr = (void*) hndl; epoll_ctl (self->ep, EPOLL_CTL_ADD, fd, &ev); } void nn_poller_rm (struct nn_poller *self, struct nn_poller_hndl *hndl) { int i; /* Remove the file descriptor from the pollset. */ epoll_ctl (self->ep, EPOLL_CTL_DEL, hndl->fd, NULL); /* Invalidate any subsequent events on this file descriptor. */ for (i = self->index; i != self->nevents; ++i) if (self->events [i].data.ptr == hndl) self->events [i].events = 0; } void nn_poller_set_in (struct nn_poller *self, struct nn_poller_hndl *hndl) { struct epoll_event ev; /* If already polling for IN, do nothing. */ if (nn_slow (hndl->events & EPOLLIN)) return; /* Start polling for IN. */ hndl->events |= EPOLLIN; memset (&ev, 0, sizeof (ev)); ev.events = hndl->events; ev.data.ptr = (void*) hndl; epoll_ctl (self->ep, EPOLL_CTL_MOD, hndl->fd, &ev); } void nn_poller_reset_in (struct nn_poller *self, struct nn_poller_hndl *hndl) { int i; struct epoll_event ev; /* If not polling for IN, do nothing. */ if (nn_slow (!(hndl->events & EPOLLIN))) return; /* Stop polling for IN. */ hndl->events &= ~EPOLLIN; memset (&ev, 0, sizeof (ev)); ev.events = hndl->events; ev.data.ptr = (void*) hndl; epoll_ctl (self->ep, EPOLL_CTL_MOD, hndl->fd, &ev); /* Invalidate any subsequent IN events on this file descriptor. */ for (i = self->index; i != self->nevents; ++i) if (self->events [i].data.ptr == hndl) self->events [i].events &= ~EPOLLIN; } void nn_poller_set_out (struct nn_poller *self, struct nn_poller_hndl *hndl) { struct epoll_event ev; int fd = hndl->fd; /* If already polling for OUT, do nothing. */ if (nn_slow (hndl->events & EPOLLOUT)) return; /* Start polling for OUT. */ hndl->events |= EPOLLOUT; memset (&ev, 0, sizeof (ev)); ev.events = hndl->events; ev.data.ptr = (void*) hndl; epoll_ctl (self->ep, EPOLL_CTL_MOD, fd, &ev); } void nn_poller_reset_out (struct nn_poller *self, struct nn_poller_hndl *hndl) { int i; struct epoll_event ev; /* If not polling for OUT, do nothing. */ if (nn_slow (!(hndl->events & EPOLLOUT))) return; /* Stop polling for OUT. */ hndl->events &= ~EPOLLOUT; memset (&ev, 0, sizeof (ev)); ev.events = hndl->events; ev.data.ptr = (void*) hndl; epoll_ctl (self->ep, EPOLL_CTL_MOD, hndl->fd, &ev); /* Invalidate any subsequent OUT events on this file descriptor. */ for (i = self->index; i != self->nevents; ++i) if (self->events [i].data.ptr == hndl) self->events [i].events &= ~EPOLLOUT; } int nn_poller_wait (struct nn_poller *self, int timeout) { int nevents; /* Clear all existing events. */ self->nevents = 0; self->index = 0; /* Wait for new events. */ while (1) { nevents = epoll_wait (self->ep, self->events, NN_POLLER_MAX_EVENTS, timeout); if (nn_slow (nevents == -1 && errno == EINTR)) continue; break; } errno_assert (self->nevents != -1); self->nevents = nevents; return 0; } int nn_poller_event (struct nn_poller *self, int *event, struct nn_poller_hndl **hndl) { /* Skip over empty events. */ while (self->index < self->nevents) { if (self->events [self->index].events != 0) break; ++self->index; } /* If there is no stored event, let the caller know. */ if (nn_slow (self->index >= self->nevents)) return -EAGAIN; /* Return next event to the caller. Remove the event from the set. */ *hndl = (struct nn_poller_hndl*) self->events [self->index].data.ptr; if (nn_fast (self->events [self->index].events & EPOLLIN)) { *event = NN_POLLER_IN; self->events [self->index].events &= ~EPOLLIN; return 0; } else if (nn_fast (self->events [self->index].events & EPOLLOUT)) { *event = NN_POLLER_OUT; self->events [self->index].events &= ~EPOLLOUT; return 0; } else { *event = NN_POLLER_ERR; ++self->index; return 0; } } nanomsg-0.8-beta/src/aio/poller_kqueue.h0000664000175000017500000000320412623652600021225 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 #include #include #define NN_POLLER_MAX_EVENTS 32 #define NN_POLLER_EVENT_IN 1 #define NN_POLLER_EVENT_OUT 2 struct nn_poller_hndl { int fd; int events; }; struct nn_poller { /* Current pollset. */ int kq; /* Number of events being processed at the moment. */ int nevents; /* Index of the event being processed at the moment. */ int index; /* Cached events. */ struct kevent events [NN_POLLER_MAX_EVENTS]; }; nanomsg-0.8-beta/src/aio/poller_kqueue.inc0000664000175000017500000001434012623652600021552 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../utils/attr.h" #include "../utils/fast.h" #include "../utils/err.h" #include "../utils/closefd.h" #include /* NetBSD has different definition of udata. */ #if defined NN_HAVE_NETBSD #define nn_poller_udata intptr_t #else #define nn_poller_udata void* #endif int nn_poller_init (struct nn_poller *self) { self->kq = kqueue (); if (self->kq == -1) { if (errno == ENFILE || errno == EMFILE) return -EMFILE; errno_assert (0); } self->nevents = 0; self->index = 0; return 0; } void nn_poller_term (struct nn_poller *self) { nn_closefd (self->kq); } void nn_poller_add (NN_UNUSED struct nn_poller *self, int fd, struct nn_poller_hndl *hndl) { /* Initialise the handle. */ hndl->fd = fd; hndl->events = 0; } void nn_poller_rm (struct nn_poller *self, struct nn_poller_hndl *hndl) { int rc; struct kevent ev; int i; if (hndl->events & NN_POLLER_EVENT_IN) { EV_SET (&ev, hndl->fd, EVFILT_READ, EV_DELETE, 0, 0, 0); kevent (self->kq, &ev, 1, NULL, 0, NULL); } if (hndl->events & NN_POLLER_EVENT_OUT) { EV_SET (&ev, hndl->fd, EVFILT_WRITE, EV_DELETE, 0, 0, 0); kevent (self->kq, &ev, 1, NULL, 0, NULL); } /* Invalidate any subsequent events on this file descriptor. */ for (i = self->index; i != self->nevents; ++i) if (self->events [i].ident == (unsigned) hndl->fd) self->events [i].udata = (nn_poller_udata) NULL; } void nn_poller_set_in (struct nn_poller *self, struct nn_poller_hndl *hndl) { int rc; struct kevent ev; int fd = hndl->fd; if (!(hndl->events & NN_POLLER_EVENT_IN)) { EV_SET (&ev, hndl->fd, EVFILT_READ, EV_ADD, 0, 0, (nn_poller_udata) hndl); rc = kevent (self->kq, &ev, 1, NULL, 0, NULL); if (rc != -1) hndl->events |= NN_POLLER_EVENT_IN; } } void nn_poller_reset_in (struct nn_poller *self, struct nn_poller_hndl *hndl) { int rc; struct kevent ev; int i; if (hndl->events & NN_POLLER_EVENT_IN) { EV_SET (&ev, hndl->fd, EVFILT_READ, EV_DELETE, 0, 0, 0); rc = kevent (self->kq, &ev, 1, NULL, 0, NULL); hndl->events &= ~NN_POLLER_EVENT_IN; } /* Invalidate any subsequent IN events on this file descriptor. */ for (i = self->index; i != self->nevents; ++i) if (self->events [i].ident == (unsigned) hndl->fd && self->events [i].filter == EVFILT_READ) self->events [i].udata = (nn_poller_udata) NULL; } void nn_poller_set_out (struct nn_poller *self, struct nn_poller_hndl *hndl) { int rc; struct kevent ev; int fd = hndl->fd; if (!(hndl->events & NN_POLLER_EVENT_OUT)) { EV_SET (&ev, fd, EVFILT_WRITE, EV_ADD, 0, 0, (nn_poller_udata) hndl); rc = kevent (self->kq, &ev, 1, NULL, 0, NULL); if (rc != -1) hndl->events |= NN_POLLER_EVENT_OUT; } } void nn_poller_reset_out (struct nn_poller *self, struct nn_poller_hndl *hndl) { int rc; struct kevent ev; int i; int fd = hndl->fd; if (hndl->events & NN_POLLER_EVENT_OUT) { EV_SET (&ev, fd, EVFILT_WRITE, EV_DELETE, 0, 0, 0); rc = kevent (self->kq, &ev, 1, NULL, 0, NULL); if (rc != -1) { hndl->events &= ~NN_POLLER_EVENT_OUT; } } /* Invalidate any subsequent OUT events on this file descriptor. */ for (i = self->index; i != self->nevents; ++i) if (self->events [i].ident == (unsigned) hndl->fd && self->events [i].filter == EVFILT_WRITE) self->events [i].udata = (nn_poller_udata) NULL; } int nn_poller_wait (struct nn_poller *self, int timeout) { struct timespec ts; int nevents; /* Clear all existing events. */ self->nevents = 0; self->index = 0; /* Wait for new events. */ #if defined NN_IGNORE_EINTR again: #endif ts.tv_sec = timeout / 1000; ts.tv_nsec = (timeout % 1000) * 1000000; nevents = kevent (self->kq, NULL, 0, &self->events [0], NN_POLLER_MAX_EVENTS, timeout >= 0 ? &ts : NULL); if (nevents == -1 && errno == EINTR) #if defined NN_IGNORE_EINTR goto again; #else return -EINTR; #endif errno_assert (nevents != -1); self->nevents = nevents; return 0; } int nn_poller_event (struct nn_poller *self, int *event, struct nn_poller_hndl **hndl) { /* Skip over empty events. */ while (self->index < self->nevents) { if (self->events [self->index].udata) break; ++self->index; } /* If there is no stored event, let the caller know. */ if (nn_slow (self->index >= self->nevents)) return -EAGAIN; /* Return next event to the caller. Remove the event from the set. */ *hndl = (struct nn_poller_hndl*) self->events [self->index].udata; if (self->events [self->index].flags & EV_EOF) *event = NN_POLLER_ERR; else if (self->events [self->index].filter == EVFILT_WRITE) *event = NN_POLLER_OUT; else if (self->events [self->index].filter == EVFILT_READ) *event = NN_POLLER_IN; else nn_assert (0); ++self->index; return 0; } nanomsg-0.8-beta/src/aio/poller_poll.h0000664000175000017500000000366312623652600020705 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 #define NN_POLLER_HAVE_ASYNC_ADD 0 struct nn_poller_hndl { int index; }; struct nn_poller { /* Actual number of elements in the pollset. */ int size; /* Index of the event being processed at the moment. */ int index; /* Number of allocated elements in the pollset. */ int capacity; /* The pollset. */ struct pollfd *pollset; /* List of handles associated with elements in the pollset. Either points to the handle associated with the file descriptor (hndl) or is part of the list of removed pollitems (removed). */ struct nn_hndls_item { struct nn_poller_hndl *hndl; int prev; int next; } *hndls; /* List of removed pollitems, linked by indices. -1 means empty list. */ int removed; }; nanomsg-0.8-beta/src/aio/poller_poll.inc0000664000175000017500000001434112623652600021222 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../utils/alloc.h" #include "../utils/err.h" #define NN_POLLER_GRANULARITY 16 int nn_poller_init (struct nn_poller *self) { self->size = 0; self->index = 0; self->capacity = NN_POLLER_GRANULARITY; self->pollset = nn_alloc (sizeof (struct pollfd) * NN_POLLER_GRANULARITY, "pollset"); alloc_assert (self->pollset); self->hndls = nn_alloc (sizeof (struct nn_hndls_item) * NN_POLLER_GRANULARITY, "hndlset"); alloc_assert (self->hndls); self->removed = -1; return 0; } void nn_poller_term (struct nn_poller *self) { nn_free (self->pollset); nn_free (self->hndls); } void nn_poller_add (struct nn_poller *self, int fd, struct nn_poller_hndl *hndl) { int rc; /* If the capacity is too low to accommodate the next item, resize it. */ if (nn_slow (self->size >= self->capacity)) { self->capacity *= 2; self->pollset = nn_realloc (self->pollset, sizeof (struct pollfd) * self->capacity); alloc_assert (self->pollset); self->hndls = nn_realloc (self->hndls, sizeof (struct nn_hndls_item) * self->capacity); alloc_assert (self->hndls); } /* Add the fd to the pollset. */ self->pollset [self->size].fd = fd; self->pollset [self->size].events = 0; self->pollset [self->size].revents = 0; hndl->index = self->size; self->hndls [self->size].hndl = hndl; ++self->size; } void nn_poller_rm (struct nn_poller *self, struct nn_poller_hndl *hndl) { /* No more events will be reported on this fd. */ self->pollset [hndl->index].revents = 0; /* Add the fd into the list of removed fds. */ if (self->removed != -1) self->hndls [self->removed].prev = hndl->index; self->hndls [hndl->index].hndl = NULL; self->hndls [hndl->index].prev = -1; self->hndls [hndl->index].next = self->removed; self->removed = hndl->index; } void nn_poller_set_in (struct nn_poller *self, struct nn_poller_hndl *hndl) { self->pollset [hndl->index].events |= POLLIN; } void nn_poller_reset_in (struct nn_poller *self, struct nn_poller_hndl *hndl) { self->pollset [hndl->index].events &= ~POLLIN; self->pollset [hndl->index].revents &= ~POLLIN; } void nn_poller_set_out (struct nn_poller *self, struct nn_poller_hndl *hndl) { self->pollset [hndl->index].events |= POLLOUT; } void nn_poller_reset_out (struct nn_poller *self, struct nn_poller_hndl *hndl) { self->pollset [hndl->index].events &= ~POLLOUT; self->pollset [hndl->index].revents &= ~POLLOUT; } int nn_poller_wait (struct nn_poller *self, int timeout) { int rc; int i; /* First, get rid of removed fds. */ while (self->removed != -1) { /* Remove the fd from the list of removed fds. */ i = self->removed; self->removed = self->hndls [i].next; /* Replace the removed fd by the one at the end of the pollset. */ --self->size; if (i != self->size) { self->pollset [i] = self->pollset [self->size]; if (self->hndls [i].next != -1) self->hndls [self->hndls [i].next].prev = -1; self->hndls [i] = self->hndls [self->size]; if (self->hndls [i].hndl) self->hndls [i].hndl->index = i; } /* The fd from the end of the pollset may have been on removed fds list itself. If so, adjust the removed list. */ if (nn_slow (!self->hndls [i].hndl)) { if (self->hndls [i].prev != -1) self->hndls [self->hndls [i].prev].next = i; if (self->hndls [i].next != -1) self->hndls [self->hndls [i].next].prev = i; if (self->removed == self->size) self->removed = i; } } self->index = 0; /* Wait for new events. */ #if defined NN_IGNORE_EINTR again: #endif rc = poll (self->pollset, self->size, timeout); if (nn_slow (rc < 0 && errno == EINTR)) #if defined NN_IGNORE_EINTR goto again; #else return -EINTR; #endif errno_assert (rc >= 0); return 0; } int nn_poller_event (struct nn_poller *self, int *event, struct nn_poller_hndl **hndl) { int rc; /* Skip over empty events. This will also skip over removed fds as they have their revents nullified. */ while (self->index < self->size) { if (self->pollset [self->index].revents != 0) break; ++self->index; } /* If there is no available event, let the caller know. */ if (nn_slow (self->index >= self->size)) return -EAGAIN; /* Return next event to the caller. Remove the event from revents. */ *hndl = self->hndls [self->index].hndl; if (nn_fast (self->pollset [self->index].revents & POLLIN)) { *event = NN_POLLER_IN; self->pollset [self->index].revents &= ~POLLIN; return 0; } else if (nn_fast (self->pollset [self->index].revents & POLLOUT)) { *event = NN_POLLER_OUT; self->pollset [self->index].revents &= ~POLLOUT; return 0; } else { *event = NN_POLLER_ERR; ++self->index; return 0; } } nanomsg-0.8-beta/src/aio/pool.h0000664000175000017500000000266112623652600017330 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_POOL_INCLUDED #define NN_POOL_INCLUDED #include "worker.h" /* Worker thread pool. */ struct nn_pool { struct nn_worker worker; }; int nn_pool_init (struct nn_pool *self); void nn_pool_term (struct nn_pool *self); struct nn_worker *nn_pool_choose_worker (struct nn_pool *self); #endif nanomsg-0.8-beta/src/aio/pool.c0000664000175000017500000000301112623652600017311 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "pool.h" /* TODO: The dummy implementation of a thread pool. As for now there's only one worker thread created. */ int nn_pool_init (struct nn_pool *self) { return nn_worker_init (&self->worker); } void nn_pool_term (struct nn_pool *self) { nn_worker_term (&self->worker); } struct nn_worker *nn_pool_choose_worker (struct nn_pool *self) { return &self->worker; } nanomsg-0.8-beta/src/aio/timer.h0000664000175000017500000000343312623652600017475 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_TIMER_INCLUDED #define NN_TIMER_INCLUDED #include "fsm.h" #include "worker.h" #define NN_TIMER_TIMEOUT 1 #define NN_TIMER_STOPPED 2 struct nn_timer { struct nn_fsm fsm; int state; struct nn_worker_task start_task; struct nn_worker_task stop_task; struct nn_worker_timer wtimer; struct nn_fsm_event done; struct nn_worker *worker; int timeout; }; void nn_timer_init (struct nn_timer *self, int src, struct nn_fsm *owner); void nn_timer_term (struct nn_timer *self); int nn_timer_isidle (struct nn_timer *self); void nn_timer_start (struct nn_timer *self, int timeout); void nn_timer_stop (struct nn_timer *self); #endif nanomsg-0.8-beta/src/aio/timer.c0000664000175000017500000001406412623652600017472 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "timer.h" #include "../utils/cont.h" #include "../utils/fast.h" #include "../utils/err.h" #include "../utils/attr.h" /* Timer state reflects the state as seen by the user thread. It says nothing about the state of affairs in the worker thread. */ #define NN_TIMER_STATE_IDLE 1 #define NN_TIMER_STATE_ACTIVE 2 #define NN_TIMER_STATE_STOPPING 3 #define NN_TIMER_SRC_START_TASK 1 #define NN_TIMER_SRC_STOP_TASK 2 /* Private functions. */ static void nn_timer_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_timer_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); void nn_timer_init (struct nn_timer *self, int src, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_timer_handler, nn_timer_shutdown, src, self, owner); self->state = NN_TIMER_STATE_IDLE; nn_worker_task_init (&self->start_task, NN_TIMER_SRC_START_TASK, &self->fsm); nn_worker_task_init (&self->stop_task, NN_TIMER_SRC_STOP_TASK, &self->fsm); nn_worker_timer_init (&self->wtimer, &self->fsm); nn_fsm_event_init (&self->done); self->worker = nn_fsm_choose_worker (&self->fsm); self->timeout = -1; } void nn_timer_term (struct nn_timer *self) { nn_assert_state (self, NN_TIMER_STATE_IDLE); nn_fsm_event_term (&self->done); nn_worker_timer_term (&self->wtimer); nn_worker_task_term (&self->stop_task); nn_worker_task_term (&self->start_task); nn_fsm_term (&self->fsm); } int nn_timer_isidle (struct nn_timer *self) { return nn_fsm_isidle (&self->fsm); } void nn_timer_start (struct nn_timer *self, int timeout) { /* Negative timeout make no sense. */ nn_assert (timeout >= 0); self->timeout = timeout; nn_fsm_start (&self->fsm); } void nn_timer_stop (struct nn_timer *self) { nn_fsm_stop (&self->fsm); } static void nn_timer_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_timer *timer; timer = nn_cont (self, struct nn_timer, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { timer->state = NN_TIMER_STATE_STOPPING; nn_worker_execute (timer->worker, &timer->stop_task); return; } if (nn_slow (timer->state == NN_TIMER_STATE_STOPPING)) { if (src != NN_TIMER_SRC_STOP_TASK) return; nn_assert (type == NN_WORKER_TASK_EXECUTE); nn_worker_rm_timer (timer->worker, &timer->wtimer); timer->state = NN_TIMER_STATE_IDLE; nn_fsm_stopped (&timer->fsm, NN_TIMER_STOPPED); return; } nn_fsm_bad_state(timer->state, src, type); } static void nn_timer_handler (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_timer *timer; timer = nn_cont (self, struct nn_timer, fsm); switch (timer->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_TIMER_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: /* Send start event to the worker thread. */ timer->state = NN_TIMER_STATE_ACTIVE; nn_worker_execute (timer->worker, &timer->start_task); return; default: nn_fsm_bad_action (timer->state, src, type); } default: nn_fsm_bad_source (timer->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /******************************************************************************/ case NN_TIMER_STATE_ACTIVE: if (src == NN_TIMER_SRC_START_TASK) { nn_assert (type == NN_WORKER_TASK_EXECUTE); nn_assert (timer->timeout >= 0); nn_worker_add_timer (timer->worker, timer->timeout, &timer->wtimer); timer->timeout = -1; return; } if (srcptr == &timer->wtimer) { switch (type) { case NN_WORKER_TIMER_TIMEOUT: /* Notify the user about the timeout. */ nn_assert (timer->timeout == -1); nn_fsm_raise (&timer->fsm, &timer->done, NN_TIMER_TIMEOUT); return; default: nn_fsm_bad_action (timer->state, src, type); } } nn_fsm_bad_source (timer->state, src, type); /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (timer->state, src, type); } } nanomsg-0.8-beta/src/aio/timerset.h0000664000175000017500000000415412623652600020212 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_TIMERSET_INCLUDED #define NN_TIMERSET_INCLUDED #include "../utils/clock.h" #include "../utils/list.h" /* This class stores a list of timeouts and reports the next one to expire along with the time till it happens. */ struct nn_timerset_hndl { struct nn_list_item list; uint64_t timeout; }; struct nn_timerset { struct nn_clock clock; struct nn_list timeouts; }; void nn_timerset_init (struct nn_timerset *self); void nn_timerset_term (struct nn_timerset *self); int nn_timerset_add (struct nn_timerset *self, int timeout, struct nn_timerset_hndl *hndl); int nn_timerset_rm (struct nn_timerset *self, struct nn_timerset_hndl *hndl); int nn_timerset_timeout (struct nn_timerset *self); int nn_timerset_event (struct nn_timerset *self, struct nn_timerset_hndl **hndl); void nn_timerset_hndl_init (struct nn_timerset_hndl *self); void nn_timerset_hndl_term (struct nn_timerset_hndl *self); int nn_timerset_hndl_isactive (struct nn_timerset_hndl *self); #endif nanomsg-0.8-beta/src/aio/timerset.c0000664000175000017500000001022712623652600020203 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "timerset.h" #include "../utils/fast.h" #include "../utils/cont.h" #include "../utils/err.h" void nn_timerset_init (struct nn_timerset *self) { nn_clock_init (&self->clock); nn_list_init (&self->timeouts); } void nn_timerset_term (struct nn_timerset *self) { nn_list_term (&self->timeouts); nn_clock_term (&self->clock); } int nn_timerset_add (struct nn_timerset *self, int timeout, struct nn_timerset_hndl *hndl) { struct nn_list_item *it; struct nn_timerset_hndl *ith; int first; /* Compute the instant when the timeout will be due. */ hndl->timeout = nn_clock_now (&self->clock) + timeout; /* Insert it into the ordered list of timeouts. */ for (it = nn_list_begin (&self->timeouts); it != nn_list_end (&self->timeouts); it = nn_list_next (&self->timeouts, it)) { ith = nn_cont (it, struct nn_timerset_hndl, list); if (hndl->timeout < ith->timeout) break; } /* If the new timeout happens to be the first one to expire, let the user know that the current waiting interval has to be changed. */ first = nn_list_begin (&self->timeouts) == it ? 1 : 0; nn_list_insert (&self->timeouts, &hndl->list, it); return first; } int nn_timerset_rm (struct nn_timerset *self, struct nn_timerset_hndl *hndl) { int first; /* Ignore if handle is not in the timeouts list. */ if (!nn_list_item_isinlist (&hndl->list)) return 0; /* If it was the first timeout that was removed, the actual waiting time may have changed. We'll thus return 1 to let the user know. */ first = nn_list_begin (&self->timeouts) == &hndl->list ? 1 : 0; nn_list_erase (&self->timeouts, &hndl->list); return first; } int nn_timerset_timeout (struct nn_timerset *self) { int timeout; if (nn_fast (nn_list_empty (&self->timeouts))) return -1; timeout = (int) (nn_cont (nn_list_begin (&self->timeouts), struct nn_timerset_hndl, list)->timeout - nn_clock_now (&self->clock)); return timeout < 0 ? 0 : timeout; } int nn_timerset_event (struct nn_timerset *self, struct nn_timerset_hndl **hndl) { struct nn_timerset_hndl *first; /* If there's no timeout, there's no event to report. */ if (nn_fast (nn_list_empty (&self->timeouts))) return -EAGAIN; /* If no timeout have expired yet, there's no event to return. */ first = nn_cont (nn_list_begin (&self->timeouts), struct nn_timerset_hndl, list); if (first->timeout > nn_clock_now (&self->clock)) return -EAGAIN; /* Return the first timeout and remove it from the list of active timeouts. */ nn_list_erase (&self->timeouts, &first->list); *hndl = first; return 0; } void nn_timerset_hndl_init (struct nn_timerset_hndl *self) { nn_list_item_init (&self->list); } void nn_timerset_hndl_term (struct nn_timerset_hndl *self) { nn_list_item_term (&self->list); } int nn_timerset_hndl_isactive (struct nn_timerset_hndl *self) { return nn_list_item_isinlist (&self->list); } nanomsg-0.8-beta/src/aio/usock.h0000664000175000017500000000716112623652600017503 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_USOCK_INCLUDED #define NN_USOCK_INCLUDED /* Import the definition of nn_iovec. */ #include "../nn.h" /* OS-level sockets. */ /* Event types generated by nn_usock. */ #define NN_USOCK_CONNECTED 1 #define NN_USOCK_ACCEPTED 2 #define NN_USOCK_SENT 3 #define NN_USOCK_RECEIVED 4 #define NN_USOCK_ERROR 5 #define NN_USOCK_ACCEPT_ERROR 6 #define NN_USOCK_STOPPED 7 #define NN_USOCK_SHUTDOWN 8 /* Maximum number of iovecs that can be passed to nn_usock_send function. */ #define NN_USOCK_MAX_IOVCNT 3 /* Size of the buffer used for batch-reads of inbound data. To keep the performance optimal make sure that this value is larger than network MTU. */ #define NN_USOCK_BATCH_SIZE 2048 #if defined NN_HAVE_WINDOWS #include "usock_win.h" #else #include "usock_posix.h" #endif void nn_usock_init (struct nn_usock *self, int src, struct nn_fsm *owner); void nn_usock_term (struct nn_usock *self); int nn_usock_isidle (struct nn_usock *self); int nn_usock_start (struct nn_usock *self, int domain, int type, int protocol); void nn_usock_start_fd (struct nn_usock *self, int fd); void nn_usock_stop (struct nn_usock *self); void nn_usock_swap_owner (struct nn_usock *self, struct nn_fsm_owner *owner); int nn_usock_setsockopt (struct nn_usock *self, int level, int optname, const void *optval, size_t optlen); int nn_usock_bind (struct nn_usock *self, const struct sockaddr *addr, size_t addrlen); int nn_usock_listen (struct nn_usock *self, int backlog); /* Accept a new connection from a listener. When done, NN_USOCK_ACCEPTED event will be delivered to the accepted socket. To cancel the operation, stop the socket being accepted. Listening socket should not be stopped while accepting a new socket is underway. */ void nn_usock_accept (struct nn_usock *self, struct nn_usock *listener); /* When all the tuning is done on the accepted socket, call this function to activate standard data transfer phase. */ void nn_usock_activate (struct nn_usock *self); /* Start connecting. Prior to this call the socket has to be bound to a local address. When connecting is done NN_USOCK_CONNECTED event will be reaised. If connecting fails NN_USOCK_ERROR event will be raised. */ void nn_usock_connect (struct nn_usock *self, const struct sockaddr *addr, size_t addrlen); void nn_usock_send (struct nn_usock *self, const struct nn_iovec *iov, int iovcnt); void nn_usock_recv (struct nn_usock *self, void *buf, size_t len, int *fd); int nn_usock_geterrno (struct nn_usock *self); #endif nanomsg-0.8-beta/src/aio/usock.c0000664000175000017500000000247412623652600017500 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "usock.h" #if defined NN_HAVE_WINDOWS #include "usock_win.inc" #else #include "usock_posix.inc" #endif int nn_usock_geterrno (struct nn_usock *self) { return self->errnum; } nanomsg-0.8-beta/src/aio/usock_posix.h0000664000175000017500000000614512623652600020726 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "fsm.h" #include "worker.h" #include #include #include struct nn_usock { /* State machine base class. */ struct nn_fsm fsm; int state; /* The worker thread the usock is associated with. */ struct nn_worker *worker; /* The underlying OS socket and handle that represents it in the poller. */ int s; struct nn_worker_fd wfd; /* Members related to receiving data. */ struct { /* The buffer being filled in at the moment. */ uint8_t *buf; size_t len; /* Buffer for batch-reading inbound data. */ uint8_t *batch; /* Size of the batch buffer. */ size_t batch_len; /* Current position in the batch buffer. The data preceding this position were already received by the user. The data that follow will be received in the future. */ size_t batch_pos; /* File descriptor received via SCM_RIGHTS, if any. */ int *pfd; } in; /* Members related to sending data. */ struct { /* msghdr being sent at the moment. */ struct msghdr hdr; /* List of buffers being sent at the moment. Referenced from 'hdr'. */ struct iovec iov [NN_USOCK_MAX_IOVCNT]; } out; /* Asynchronous tasks for the worker. */ struct nn_worker_task task_connecting; struct nn_worker_task task_connected; struct nn_worker_task task_accept; struct nn_worker_task task_send; struct nn_worker_task task_recv; struct nn_worker_task task_stop; /* Events raised by the usock. */ struct nn_fsm_event event_established; struct nn_fsm_event event_sent; struct nn_fsm_event event_received; struct nn_fsm_event event_error; /* In ACCEPTING state points to the socket being accepted. In BEING_ACCEPTED state points to the listener socket. */ struct nn_usock *asock; /* Errno remembered in NN_USOCK_ERROR state */ int errnum; }; nanomsg-0.8-beta/src/aio/usock_posix.inc0000664000175000017500000012106412623652600021246 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. All rights reserved. Copyright 2015 Garrett D'Amore 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 "../utils/alloc.h" #include "../utils/closefd.h" #include "../utils/cont.h" #include "../utils/fast.h" #include "../utils/err.h" #include "../utils/attr.h" #include #include #include #include #define NN_USOCK_STATE_IDLE 1 #define NN_USOCK_STATE_STARTING 2 #define NN_USOCK_STATE_BEING_ACCEPTED 3 #define NN_USOCK_STATE_ACCEPTED 4 #define NN_USOCK_STATE_CONNECTING 5 #define NN_USOCK_STATE_ACTIVE 6 #define NN_USOCK_STATE_REMOVING_FD 7 #define NN_USOCK_STATE_DONE 8 #define NN_USOCK_STATE_LISTENING 9 #define NN_USOCK_STATE_ACCEPTING 10 #define NN_USOCK_STATE_CANCELLING 11 #define NN_USOCK_STATE_STOPPING 12 #define NN_USOCK_STATE_STOPPING_ACCEPT 13 #define NN_USOCK_STATE_ACCEPTING_ERROR 14 #define NN_USOCK_ACTION_ACCEPT 1 #define NN_USOCK_ACTION_BEING_ACCEPTED 2 #define NN_USOCK_ACTION_CANCEL 3 #define NN_USOCK_ACTION_LISTEN 4 #define NN_USOCK_ACTION_CONNECT 5 #define NN_USOCK_ACTION_ACTIVATE 6 #define NN_USOCK_ACTION_DONE 7 #define NN_USOCK_ACTION_ERROR 8 #define NN_USOCK_ACTION_STARTED 9 #define NN_USOCK_SRC_FD 1 #define NN_USOCK_SRC_TASK_CONNECTING 2 #define NN_USOCK_SRC_TASK_CONNECTED 3 #define NN_USOCK_SRC_TASK_ACCEPT 4 #define NN_USOCK_SRC_TASK_SEND 5 #define NN_USOCK_SRC_TASK_RECV 6 #define NN_USOCK_SRC_TASK_STOP 7 /* Private functions. */ static void nn_usock_init_from_fd (struct nn_usock *self, int s); static int nn_usock_send_raw (struct nn_usock *self, struct msghdr *hdr); static int nn_usock_recv_raw (struct nn_usock *self, void *buf, size_t *len); static int nn_usock_geterr (struct nn_usock *self); static void nn_usock_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_usock_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); void nn_usock_init (struct nn_usock *self, int src, struct nn_fsm *owner) { /* Initalise the state machine. */ nn_fsm_init (&self->fsm, nn_usock_handler, nn_usock_shutdown, src, self, owner); self->state = NN_USOCK_STATE_IDLE; /* Choose a worker thread to handle this socket. */ self->worker = nn_fsm_choose_worker (&self->fsm); /* Actual file descriptor will be generated during 'start' step. */ self->s = -1; self->errnum = 0; self->in.buf = NULL; self->in.len = 0; self->in.batch = NULL; self->in.batch_len = 0; self->in.batch_pos = 0; self->in.pfd = NULL; memset (&self->out.hdr, 0, sizeof (struct msghdr)); /* Initialise tasks for the worker thread. */ nn_worker_fd_init (&self->wfd, NN_USOCK_SRC_FD, &self->fsm); nn_worker_task_init (&self->task_connecting, NN_USOCK_SRC_TASK_CONNECTING, &self->fsm); nn_worker_task_init (&self->task_connected, NN_USOCK_SRC_TASK_CONNECTED, &self->fsm); nn_worker_task_init (&self->task_accept, NN_USOCK_SRC_TASK_ACCEPT, &self->fsm); nn_worker_task_init (&self->task_send, NN_USOCK_SRC_TASK_SEND, &self->fsm); nn_worker_task_init (&self->task_recv, NN_USOCK_SRC_TASK_RECV, &self->fsm); nn_worker_task_init (&self->task_stop, NN_USOCK_SRC_TASK_STOP, &self->fsm); /* Intialise events raised by usock. */ nn_fsm_event_init (&self->event_established); nn_fsm_event_init (&self->event_sent); nn_fsm_event_init (&self->event_received); nn_fsm_event_init (&self->event_error); /* accepting is not going on at the moment. */ self->asock = NULL; } void nn_usock_term (struct nn_usock *self) { nn_assert_state (self, NN_USOCK_STATE_IDLE); if (self->in.batch) nn_free (self->in.batch); nn_fsm_event_term (&self->event_error); nn_fsm_event_term (&self->event_received); nn_fsm_event_term (&self->event_sent); nn_fsm_event_term (&self->event_established); nn_worker_cancel (self->worker, &self->task_recv); nn_worker_task_term (&self->task_stop); nn_worker_task_term (&self->task_recv); nn_worker_task_term (&self->task_send); nn_worker_task_term (&self->task_accept); nn_worker_task_term (&self->task_connected); nn_worker_task_term (&self->task_connecting); nn_worker_fd_term (&self->wfd); nn_fsm_term (&self->fsm); } int nn_usock_isidle (struct nn_usock *self) { return nn_fsm_isidle (&self->fsm); } int nn_usock_start (struct nn_usock *self, int domain, int type, int protocol) { int s; /* If the operating system allows to directly open the socket with CLOEXEC flag, do so. That way there are no race conditions. */ #ifdef SOCK_CLOEXEC type |= SOCK_CLOEXEC; #endif /* Open the underlying socket. */ s = socket (domain, type, protocol); if (nn_slow (s < 0)) return -errno; nn_usock_init_from_fd (self, s); /* Start the state machine. */ nn_fsm_start (&self->fsm); return 0; } void nn_usock_start_fd (struct nn_usock *self, int fd) { nn_usock_init_from_fd (self, fd); nn_fsm_start (&self->fsm); nn_fsm_action (&self->fsm, NN_USOCK_ACTION_STARTED); } static void nn_usock_init_from_fd (struct nn_usock *self, int s) { int rc; int opt; nn_assert (self->state == NN_USOCK_STATE_IDLE || NN_USOCK_STATE_BEING_ACCEPTED); /* Store the file descriptor. */ nn_assert (self->s == -1); self->s = s; /* Setting FD_CLOEXEC option immediately after socket creation is the second best option after using SOCK_CLOEXEC. There is a race condition here (if process is forked between socket creation and setting the option) but the problem is pretty unlikely to happen. */ #if defined FD_CLOEXEC rc = fcntl (self->s, F_SETFD, FD_CLOEXEC); #if defined NN_HAVE_OSX errno_assert (rc != -1 || errno == EINVAL); #else errno_assert (rc != -1); #endif #endif /* If applicable, prevent SIGPIPE signal when writing to the connection already closed by the peer. */ #ifdef SO_NOSIGPIPE opt = 1; rc = setsockopt (self->s, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof (opt)); #if defined NN_HAVE_OSX errno_assert (rc == 0 || errno == EINVAL); #else errno_assert (rc == 0); #endif #endif /* Switch the socket to the non-blocking mode. All underlying sockets are always used in the callbackhronous mode. */ opt = fcntl (self->s, F_GETFL, 0); if (opt == -1) opt = 0; if (!(opt & O_NONBLOCK)) { rc = fcntl (self->s, F_SETFL, opt | O_NONBLOCK); #if defined NN_HAVE_OSX errno_assert (rc != -1 || errno == EINVAL); #else errno_assert (rc != -1); #endif } } void nn_usock_stop (struct nn_usock *self) { nn_fsm_stop (&self->fsm); } void nn_usock_async_stop (struct nn_usock *self) { nn_worker_execute (self->worker, &self->task_stop); nn_fsm_raise (&self->fsm, &self->event_error, NN_USOCK_SHUTDOWN); } void nn_usock_swap_owner (struct nn_usock *self, struct nn_fsm_owner *owner) { nn_fsm_swap_owner (&self->fsm, owner); } int nn_usock_setsockopt (struct nn_usock *self, int level, int optname, const void *optval, size_t optlen) { int rc; /* The socket can be modified only before it's active. */ nn_assert (self->state == NN_USOCK_STATE_STARTING || self->state == NN_USOCK_STATE_ACCEPTED); /* EINVAL errors are ignored on OSX platform. The reason for that is buggy OSX behaviour where setsockopt returns EINVAL if the peer have already disconnected. Thus, nn_usock_setsockopt() can succeed on OSX even though the option value was invalid, but the peer have already closed the connection. This behaviour should be relatively harmless. */ rc = setsockopt (self->s, level, optname, optval, (socklen_t) optlen); #if defined NN_HAVE_OSX if (nn_slow (rc != 0 && errno != EINVAL)) return -errno; #else if (nn_slow (rc != 0)) return -errno; #endif return 0; } int nn_usock_bind (struct nn_usock *self, const struct sockaddr *addr, size_t addrlen) { int rc; int opt; /* The socket can be bound only before it's connected. */ nn_assert_state (self, NN_USOCK_STATE_STARTING); /* Allow re-using the address. */ opt = 1; rc = setsockopt (self->s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof (opt)); errno_assert (rc == 0); rc = bind (self->s, addr, (socklen_t) addrlen); if (nn_slow (rc != 0)) return -errno; return 0; } int nn_usock_listen (struct nn_usock *self, int backlog) { int rc; /* You can start listening only before the socket is connected. */ nn_assert_state (self, NN_USOCK_STATE_STARTING); /* Start listening for incoming connections. */ rc = listen (self->s, backlog); if (nn_slow (rc != 0)) return -errno; /* Notify the state machine. */ nn_fsm_action (&self->fsm, NN_USOCK_ACTION_LISTEN); return 0; } void nn_usock_accept (struct nn_usock *self, struct nn_usock *listener) { int s; /* Start the actual accepting. */ if (nn_fsm_isidle(&self->fsm)) { nn_fsm_start (&self->fsm); nn_fsm_action (&self->fsm, NN_USOCK_ACTION_BEING_ACCEPTED); } nn_fsm_action (&listener->fsm, NN_USOCK_ACTION_ACCEPT); /* Try to accept new connection in synchronous manner. */ #if NN_HAVE_ACCEPT4 s = accept4 (listener->s, NULL, NULL, SOCK_CLOEXEC); #else s = accept (listener->s, NULL, NULL); #endif /* Immediate success. */ if (nn_fast (s >= 0)) { /* Disassociate the listener socket from the accepted socket. Is useful if we restart accepting on ACCEPT_ERROR */ listener->asock = NULL; self->asock = NULL; nn_usock_init_from_fd (self, s); nn_fsm_action (&listener->fsm, NN_USOCK_ACTION_DONE); nn_fsm_action (&self->fsm, NN_USOCK_ACTION_DONE); return; } /* Detect a failure. Note that in ECONNABORTED case we simply ignore the error and wait for next connection in asynchronous manner. */ errno_assert (errno == EAGAIN || errno == EWOULDBLOCK || errno == ECONNABORTED || errno == ENFILE || errno == EMFILE || errno == ENOBUFS || errno == ENOMEM); /* Pair the two sockets. They are already paired in case previous attempt failed on ACCEPT_ERROR */ nn_assert (!self->asock || self->asock == listener); self->asock = listener; nn_assert (!listener->asock || listener->asock == self); listener->asock = self; /* Some errors are just ok to ignore for now. We also stop repeating any errors until next IN_FD event so that we are not in a tight loop and allow processing other events in the meantime */ if (nn_slow (errno != EAGAIN && errno != EWOULDBLOCK && errno != ECONNABORTED && errno != listener->errnum)) { listener->errnum = errno; listener->state = NN_USOCK_STATE_ACCEPTING_ERROR; nn_fsm_raise (&listener->fsm, &listener->event_error, NN_USOCK_ACCEPT_ERROR); return; } /* Ask the worker thread to wait for the new connection. */ nn_worker_execute (listener->worker, &listener->task_accept); } void nn_usock_activate (struct nn_usock *self) { nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ACTIVATE); } void nn_usock_connect (struct nn_usock *self, const struct sockaddr *addr, size_t addrlen) { int rc; /* Notify the state machine that we've started connecting. */ nn_fsm_action (&self->fsm, NN_USOCK_ACTION_CONNECT); /* Do the connect itself. */ rc = connect (self->s, addr, (socklen_t) addrlen); /* Immediate success. */ if (nn_fast (rc == 0)) { nn_fsm_action (&self->fsm, NN_USOCK_ACTION_DONE); return; } /* Immediate error. */ if (nn_slow (errno != EINPROGRESS)) { self->errnum = errno; nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ERROR); return; } /* Start asynchronous connect. */ nn_worker_execute (self->worker, &self->task_connecting); } void nn_usock_send (struct nn_usock *self, const struct nn_iovec *iov, int iovcnt) { int rc; int i; int out; /* Make sure that the socket is actually alive. */ nn_assert_state (self, NN_USOCK_STATE_ACTIVE); /* Copy the iovecs to the socket. */ nn_assert (iovcnt <= NN_USOCK_MAX_IOVCNT); self->out.hdr.msg_iov = self->out.iov; out = 0; for (i = 0; i != iovcnt; ++i) { if (iov [i].iov_len == 0) continue; self->out.iov [out].iov_base = iov [i].iov_base; self->out.iov [out].iov_len = iov [i].iov_len; out++; } self->out.hdr.msg_iovlen = out; /* Try to send the data immediately. */ rc = nn_usock_send_raw (self, &self->out.hdr); /* Success. */ if (nn_fast (rc == 0)) { nn_fsm_raise (&self->fsm, &self->event_sent, NN_USOCK_SENT); return; } /* Errors. */ if (nn_slow (rc != -EAGAIN)) { errnum_assert (rc == -ECONNRESET, -rc); nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ERROR); return; } /* Ask the worker thread to send the remaining data. */ nn_worker_execute (self->worker, &self->task_send); } void nn_usock_recv (struct nn_usock *self, void *buf, size_t len, int *fd) { int rc; size_t nbytes; /* Make sure that the socket is actually alive. */ nn_assert_state (self, NN_USOCK_STATE_ACTIVE); /* Try to receive the data immediately. */ nbytes = len; self->in.pfd = fd; rc = nn_usock_recv_raw (self, buf, &nbytes); if (nn_slow (rc < 0)) { errnum_assert (rc == -ECONNRESET, -rc); nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ERROR); return; } /* Success. */ if (nn_fast (nbytes == len)) { nn_fsm_raise (&self->fsm, &self->event_received, NN_USOCK_RECEIVED); return; } /* There are still data to receive in the background. */ self->in.buf = ((uint8_t*) buf) + nbytes; self->in.len = len - nbytes; /* Ask the worker thread to receive the remaining data. */ nn_worker_execute (self->worker, &self->task_recv); } static int nn_internal_tasks (struct nn_usock *usock, int src, int type) { /******************************************************************************/ /* Internal tasks sent from the user thread to the worker thread. */ /******************************************************************************/ switch (src) { case NN_USOCK_SRC_TASK_SEND: nn_assert (type == NN_WORKER_TASK_EXECUTE); nn_worker_set_out (usock->worker, &usock->wfd); return 1; case NN_USOCK_SRC_TASK_RECV: nn_assert (type == NN_WORKER_TASK_EXECUTE); nn_worker_set_in (usock->worker, &usock->wfd); return 1; case NN_USOCK_SRC_TASK_CONNECTED: nn_assert (type == NN_WORKER_TASK_EXECUTE); nn_worker_add_fd (usock->worker, usock->s, &usock->wfd); return 1; case NN_USOCK_SRC_TASK_CONNECTING: nn_assert (type == NN_WORKER_TASK_EXECUTE); nn_worker_add_fd (usock->worker, usock->s, &usock->wfd); nn_worker_set_out (usock->worker, &usock->wfd); return 1; case NN_USOCK_SRC_TASK_ACCEPT: nn_assert (type == NN_WORKER_TASK_EXECUTE); nn_worker_add_fd (usock->worker, usock->s, &usock->wfd); nn_worker_set_in (usock->worker, &usock->wfd); return 1; } return 0; } static void nn_usock_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_usock *usock; usock = nn_cont (self, struct nn_usock, fsm); if (nn_internal_tasks (usock, src, type)) return; if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { /* Socket in ACCEPTING or CANCELLING state cannot be closed. Stop the socket being accepted first. */ nn_assert (usock->state != NN_USOCK_STATE_ACCEPTING && usock->state != NN_USOCK_STATE_CANCELLING); usock->errnum = 0; /* Synchronous stop. */ if (usock->state == NN_USOCK_STATE_IDLE) goto finish3; if (usock->state == NN_USOCK_STATE_DONE) goto finish2; if (usock->state == NN_USOCK_STATE_STARTING || usock->state == NN_USOCK_STATE_ACCEPTED || usock->state == NN_USOCK_STATE_ACCEPTING_ERROR || usock->state == NN_USOCK_STATE_LISTENING) goto finish1; /* When socket that's being accepted is asked to stop, we have to ask the listener socket to stop accepting first. */ if (usock->state == NN_USOCK_STATE_BEING_ACCEPTED) { nn_fsm_action (&usock->asock->fsm, NN_USOCK_ACTION_CANCEL); usock->state = NN_USOCK_STATE_STOPPING_ACCEPT; return; } /* Asynchronous stop. */ if (usock->state != NN_USOCK_STATE_REMOVING_FD) nn_usock_async_stop (usock); usock->state = NN_USOCK_STATE_STOPPING; return; } if (nn_slow (usock->state == NN_USOCK_STATE_STOPPING_ACCEPT)) { nn_assert (src == NN_FSM_ACTION && type == NN_USOCK_ACTION_DONE); goto finish2; } if (nn_slow (usock->state == NN_USOCK_STATE_STOPPING)) { if (src != NN_USOCK_SRC_TASK_STOP) return; nn_assert (type == NN_WORKER_TASK_EXECUTE); nn_worker_rm_fd (usock->worker, &usock->wfd); finish1: nn_closefd (usock->s); usock->s = -1; finish2: usock->state = NN_USOCK_STATE_IDLE; nn_fsm_stopped (&usock->fsm, NN_USOCK_STOPPED); finish3: return; } nn_fsm_bad_state(usock->state, src, type); } static void nn_usock_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { int rc; struct nn_usock *usock; int s; size_t sz; int sockerr; usock = nn_cont (self, struct nn_usock, fsm); if(nn_internal_tasks(usock, src, type)) return; switch (usock->state) { /******************************************************************************/ /* IDLE state. */ /* nn_usock object is initialised, but underlying OS socket is not yet */ /* created. */ /******************************************************************************/ case NN_USOCK_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: usock->state = NN_USOCK_STATE_STARTING; return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /******************************************************************************/ /* STARTING state. */ /* Underlying OS socket is created, but it's not yet passed to the worker */ /* thread. In this state we can set socket options, local and remote */ /* address etc. */ /******************************************************************************/ case NN_USOCK_STATE_STARTING: /* Events from the owner of the usock. */ switch (src) { case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_LISTEN: usock->state = NN_USOCK_STATE_LISTENING; return; case NN_USOCK_ACTION_CONNECT: usock->state = NN_USOCK_STATE_CONNECTING; return; case NN_USOCK_ACTION_BEING_ACCEPTED: usock->state = NN_USOCK_STATE_BEING_ACCEPTED; return; case NN_USOCK_ACTION_STARTED: nn_worker_add_fd (usock->worker, usock->s, &usock->wfd); usock->state = NN_USOCK_STATE_ACTIVE; return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /******************************************************************************/ /* BEING_ACCEPTED state. */ /* accept() was called on the usock. Now the socket is waiting for a new */ /* connection to arrive. */ /******************************************************************************/ case NN_USOCK_STATE_BEING_ACCEPTED: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_DONE: usock->state = NN_USOCK_STATE_ACCEPTED; nn_fsm_raise (&usock->fsm, &usock->event_established, NN_USOCK_ACCEPTED); return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /******************************************************************************/ /* ACCEPTED state. */ /* Connection was accepted, now it can be tuned. Afterwards, it'll move to */ /* the active state. */ /******************************************************************************/ case NN_USOCK_STATE_ACCEPTED: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_ACTIVATE: nn_worker_add_fd (usock->worker, usock->s, &usock->wfd); usock->state = NN_USOCK_STATE_ACTIVE; return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /******************************************************************************/ /* CONNECTING state. */ /* Asynchronous connecting is going on. */ /******************************************************************************/ case NN_USOCK_STATE_CONNECTING: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_DONE: usock->state = NN_USOCK_STATE_ACTIVE; nn_worker_execute (usock->worker, &usock->task_connected); nn_fsm_raise (&usock->fsm, &usock->event_established, NN_USOCK_CONNECTED); return; case NN_USOCK_ACTION_ERROR: nn_closefd (usock->s); usock->s = -1; usock->state = NN_USOCK_STATE_DONE; nn_fsm_raise (&usock->fsm, &usock->event_error, NN_USOCK_ERROR); return; default: nn_fsm_bad_action (usock->state, src, type); } case NN_USOCK_SRC_FD: switch (type) { case NN_WORKER_FD_OUT: nn_worker_reset_out (usock->worker, &usock->wfd); usock->state = NN_USOCK_STATE_ACTIVE; sockerr = nn_usock_geterr(usock); if (sockerr == 0) { nn_fsm_raise (&usock->fsm, &usock->event_established, NN_USOCK_CONNECTED); } else { usock->errnum = sockerr; nn_worker_rm_fd (usock->worker, &usock->wfd); rc = close (usock->s); errno_assert (rc == 0); usock->s = -1; usock->state = NN_USOCK_STATE_DONE; nn_fsm_raise (&usock->fsm, &usock->event_error, NN_USOCK_ERROR); } return; case NN_WORKER_FD_ERR: nn_worker_rm_fd (usock->worker, &usock->wfd); nn_closefd (usock->s); usock->s = -1; usock->state = NN_USOCK_STATE_DONE; nn_fsm_raise (&usock->fsm, &usock->event_error, NN_USOCK_ERROR); return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /* Socket is connected. It can be used for sending and receiving data. */ /******************************************************************************/ case NN_USOCK_STATE_ACTIVE: switch (src) { case NN_USOCK_SRC_FD: switch (type) { case NN_WORKER_FD_IN: sz = usock->in.len; rc = nn_usock_recv_raw (usock, usock->in.buf, &sz); if (nn_fast (rc == 0)) { usock->in.len -= sz; usock->in.buf += sz; if (!usock->in.len) { nn_worker_reset_in (usock->worker, &usock->wfd); nn_fsm_raise (&usock->fsm, &usock->event_received, NN_USOCK_RECEIVED); } return; } errnum_assert (rc == -ECONNRESET, -rc); goto error; case NN_WORKER_FD_OUT: rc = nn_usock_send_raw (usock, &usock->out.hdr); if (nn_fast (rc == 0)) { nn_worker_reset_out (usock->worker, &usock->wfd); nn_fsm_raise (&usock->fsm, &usock->event_sent, NN_USOCK_SENT); return; } if (nn_fast (rc == -EAGAIN)) return; errnum_assert (rc == -ECONNRESET, -rc); goto error; case NN_WORKER_FD_ERR: error: nn_worker_rm_fd (usock->worker, &usock->wfd); nn_closefd (usock->s); usock->s = -1; usock->state = NN_USOCK_STATE_DONE; nn_fsm_raise (&usock->fsm, &usock->event_error, NN_USOCK_ERROR); return; default: nn_fsm_bad_action (usock->state, src, type); } case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_ERROR: usock->state = NN_USOCK_STATE_REMOVING_FD; nn_usock_async_stop (usock); return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source(usock->state, src, type); } /******************************************************************************/ /* REMOVING_FD state. */ /******************************************************************************/ case NN_USOCK_STATE_REMOVING_FD: switch (src) { case NN_USOCK_SRC_TASK_STOP: switch (type) { case NN_WORKER_TASK_EXECUTE: nn_worker_rm_fd (usock->worker, &usock->wfd); nn_closefd (usock->s); usock->s = -1; usock->state = NN_USOCK_STATE_DONE; nn_fsm_raise (&usock->fsm, &usock->event_error, NN_USOCK_ERROR); return; default: nn_fsm_bad_action (usock->state, src, type); } /* Events from the file descriptor are ignored while it is being removed. */ case NN_USOCK_SRC_FD: return; default: nn_fsm_bad_source (usock->state, src, type); } /******************************************************************************/ /* DONE state. */ /* Socket is closed. The only thing that can be done in this state is */ /* stopping the usock. */ /******************************************************************************/ case NN_USOCK_STATE_DONE: nn_fsm_bad_source (usock->state, src, type); /******************************************************************************/ /* LISTENING state. */ /* Socket is listening for new incoming connections, however, user is not */ /* accepting a new connection. */ /******************************************************************************/ case NN_USOCK_STATE_LISTENING: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_ACCEPT: usock->state = NN_USOCK_STATE_ACCEPTING; return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /******************************************************************************/ /* ACCEPTING state. */ /* User is waiting asynchronouslyfor a new inbound connection */ /* to be accepted. */ /******************************************************************************/ case NN_USOCK_STATE_ACCEPTING: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_DONE: usock->state = NN_USOCK_STATE_LISTENING; return; case NN_USOCK_ACTION_CANCEL: usock->state = NN_USOCK_STATE_CANCELLING; nn_worker_execute (usock->worker, &usock->task_stop); return; default: nn_fsm_bad_action (usock->state, src, type); } case NN_USOCK_SRC_FD: switch (type) { case NN_WORKER_FD_IN: /* New connection arrived in asynchronous manner. */ #if NN_HAVE_ACCEPT4 s = accept4 (usock->s, NULL, NULL, SOCK_CLOEXEC); #else s = accept (usock->s, NULL, NULL); #endif /* ECONNABORTED is an valid error. New connection was closed by the peer before we were able to accept it. If it happens do nothing and wait for next incoming connection. */ if (nn_slow (s < 0 && errno == ECONNABORTED)) return; /* Resource allocation errors. It's not clear from POSIX specification whether the new connection is closed in this case or whether it remains in the backlog. In the latter case it would be wise to wait here for a while to prevent busy looping. */ if (nn_slow (s < 0 && (errno == ENFILE || errno == EMFILE || errno == ENOBUFS || errno == ENOMEM))) { usock->errnum = errno; usock->state = NN_USOCK_STATE_ACCEPTING_ERROR; /* Wait till the user starts accepting once again. */ nn_worker_rm_fd (usock->worker, &usock->wfd); nn_fsm_raise (&usock->fsm, &usock->event_error, NN_USOCK_ACCEPT_ERROR); return; } /* Any other error is unexpected. */ errno_assert (s >= 0); /* Initialise the new usock object. */ nn_usock_init_from_fd (usock->asock, s); usock->asock->state = NN_USOCK_STATE_ACCEPTED; /* Notify the user that connection was accepted. */ nn_fsm_raise (&usock->asock->fsm, &usock->asock->event_established, NN_USOCK_ACCEPTED); /* Disassociate the listener socket from the accepted socket. */ usock->asock->asock = NULL; usock->asock = NULL; /* Wait till the user starts accepting once again. */ nn_worker_rm_fd (usock->worker, &usock->wfd); usock->state = NN_USOCK_STATE_LISTENING; return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /******************************************************************************/ /* ACCEPTING_ERROR state. */ /* Waiting the socket to accept the error and restart */ /******************************************************************************/ case NN_USOCK_STATE_ACCEPTING_ERROR: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_ACCEPT: usock->state = NN_USOCK_STATE_ACCEPTING; return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /******************************************************************************/ /* CANCELLING state. */ /******************************************************************************/ case NN_USOCK_STATE_CANCELLING: switch (src) { case NN_USOCK_SRC_TASK_STOP: switch (type) { case NN_WORKER_TASK_EXECUTE: nn_worker_rm_fd (usock->worker, &usock->wfd); usock->state = NN_USOCK_STATE_LISTENING; /* Notify the accepted socket that it was stopped. */ nn_fsm_action (&usock->asock->fsm, NN_USOCK_ACTION_DONE); return; default: nn_fsm_bad_action (usock->state, src, type); } case NN_USOCK_SRC_FD: switch (type) { case NN_WORKER_FD_IN: return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /******************************************************************************/ /* Invalid state */ /******************************************************************************/ default: nn_fsm_bad_state (usock->state, src, type); } } static int nn_usock_send_raw (struct nn_usock *self, struct msghdr *hdr) { ssize_t nbytes; /* Try to send the data. */ #if defined MSG_NOSIGNAL nbytes = sendmsg (self->s, hdr, MSG_NOSIGNAL); #else nbytes = sendmsg (self->s, hdr, 0); #endif /* Handle errors. */ if (nn_slow (nbytes < 0)) { if (nn_fast (errno == EAGAIN || errno == EWOULDBLOCK)) nbytes = 0; else { /* If the connection fails, return ECONNRESET. */ return -ECONNRESET; } } /* Some bytes were sent. Adjust the iovecs accordingly. */ while (nbytes) { if (nbytes >= (ssize_t)hdr->msg_iov->iov_len) { --hdr->msg_iovlen; if (!hdr->msg_iovlen) { nn_assert (nbytes == (ssize_t)hdr->msg_iov->iov_len); return 0; } nbytes -= hdr->msg_iov->iov_len; ++hdr->msg_iov; } else { *((uint8_t**) &(hdr->msg_iov->iov_base)) += nbytes; hdr->msg_iov->iov_len -= nbytes; return -EAGAIN; } } if (hdr->msg_iovlen > 0) return -EAGAIN; return 0; } static int nn_usock_recv_raw (struct nn_usock *self, void *buf, size_t *len) { size_t sz; size_t length; ssize_t nbytes; struct iovec iov; struct msghdr hdr; unsigned char ctrl [256]; #if defined NN_HAVE_MSG_CONTROL struct cmsghdr *cmsg; #endif /* If batch buffer doesn't exist, allocate it. The point of delayed deallocation to allow non-receiving sockets, such as TCP listening sockets, to do without the batch buffer. */ if (nn_slow (!self->in.batch)) { self->in.batch = nn_alloc (NN_USOCK_BATCH_SIZE, "AIO batch buffer"); alloc_assert (self->in.batch); } /* Try to satisfy the recv request by data from the batch buffer. */ length = *len; sz = self->in.batch_len - self->in.batch_pos; if (sz) { if (sz > length) sz = length; memcpy (buf, self->in.batch + self->in.batch_pos, sz); self->in.batch_pos += sz; buf = ((char*) buf) + sz; length -= sz; if (!length) return 0; } /* If recv request is greater than the batch buffer, get the data directly into the place. Otherwise, read data to the batch buffer. */ if (length > NN_USOCK_BATCH_SIZE) { iov.iov_base = buf; iov.iov_len = length; } else { iov.iov_base = self->in.batch; iov.iov_len = NN_USOCK_BATCH_SIZE; } memset (&hdr, 0, sizeof (hdr)); hdr.msg_iov = &iov; hdr.msg_iovlen = 1; #if defined NN_HAVE_MSG_CONTROL hdr.msg_control = ctrl; hdr.msg_controllen = sizeof (ctrl); #else *((int*) ctrl) = -1; hdr.msg_accrights = ctrl; hdr.msg_accrightslen = sizeof (int); #endif nbytes = recvmsg (self->s, &hdr, 0); /* Handle any possible errors. */ if (nn_slow (nbytes <= 0)) { if (nn_slow (nbytes == 0)) return -ECONNRESET; /* Zero bytes received. */ if (nn_fast (errno == EAGAIN || errno == EWOULDBLOCK)) nbytes = 0; else { /* If the peer closes the connection, return ECONNRESET. */ return -ECONNRESET; } } /* Extract the associated file descriptor, if any. */ if (nbytes > 0) { #if defined NN_HAVE_MSG_CONTROL cmsg = CMSG_FIRSTHDR (&hdr); while (cmsg) { if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { if (self->in.pfd) { *self->in.pfd = *((int*) CMSG_DATA (cmsg)); self->in.pfd = NULL; } else { nn_closefd (*((int*) CMSG_DATA (cmsg))); } break; } cmsg = CMSG_NXTHDR (&hdr, cmsg); } #else if (hdr.msg_accrightslen > 0) { nn_assert (hdr.msg_accrightslen == sizeof (int)); if (self->in.pfd) { *self->in.pfd = *((int*) hdr.msg_accrights); self->in.pfd = NULL; } else { nn_closefd (*((int*) hdr.msg_accrights)); } } #endif } /* If the data were received directly into the place we can return straight away. */ if (length > NN_USOCK_BATCH_SIZE) { length -= nbytes; *len -= length; return 0; } /* New data were read to the batch buffer. Copy the requested amount of it to the user-supplied buffer. */ self->in.batch_len = nbytes; self->in.batch_pos = 0; if (nbytes) { sz = nbytes > (ssize_t)length ? length : (size_t)nbytes; memcpy (buf, self->in.batch, sz); length -= sz; self->in.batch_pos += sz; } *len -= length; return 0; } static int nn_usock_geterr (struct nn_usock *self) { int rc; int opt; #if defined NN_HAVE_HPUX int optsz; #else socklen_t optsz; #endif opt = 0; optsz = sizeof (opt); rc = getsockopt (self->s, SOL_SOCKET, SO_ERROR, &opt, &optsz); /* The following should handle both Solaris and UNIXes derived from BSD. */ if (rc == -1) return errno; errno_assert (rc == 0); nn_assert (optsz == sizeof (opt)); return opt; } nanomsg-0.8-beta/src/aio/usock_win.h0000664000175000017500000000536512623652600020364 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "fsm.h" #include "worker.h" #include "../utils/win.h" struct nn_usock { /* The state machine. */ struct nn_fsm fsm; int state; union { /* The actual underlying socket. Can be used as a HANDLE too. */ SOCKET s; /* Named pipe handle. Cannot be used as a SOCKET. */ HANDLE p; }; /* For NamedPipes, closing an accepted pipe differs from other pipes. If the NamedPipe was accepted, this member is set to 1. 0 otherwise. */ int isaccepted; /* Asynchronous operations being executed on the socket. */ struct nn_worker_op in; struct nn_worker_op out; /* When accepting new socket, they have to be created with same type as the listening socket. Thus, in listening socket we have to store its exact type. */ int domain; int type; int protocol; /* Events raised by the usock. */ struct nn_fsm_event event_established; struct nn_fsm_event event_sent; struct nn_fsm_event event_received; struct nn_fsm_event event_error; /* In ACCEPTING state points to the socket being accepted. In BEING_ACCEPTED state points to the listener socket. */ struct nn_usock *asock; /* Buffer allocated for output of AcceptEx function. If accepting is not done on this socket, the field is set to NULL. */ void *ainfo; /* For NamedPipes, we store the address inside the socket. */ struct sockaddr_un pipename; /* For now we allocate a new buffer for each write to a named pipe. */ void *pipesendbuf; /* Errno remembered in NN_USOCK_ERROR state */ int errnum; }; nanomsg-0.8-beta/src/aio/usock_win.inc0000664000175000017500000010451312623652600020701 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "worker.h" #include "../utils/err.h" #include "../utils/cont.h" #include "../utils/alloc.h" #include #include #include #define NN_USOCK_STATE_IDLE 1 #define NN_USOCK_STATE_STARTING 2 #define NN_USOCK_STATE_BEING_ACCEPTED 3 #define NN_USOCK_STATE_ACCEPTED 4 #define NN_USOCK_STATE_CONNECTING 5 #define NN_USOCK_STATE_ACTIVE 6 #define NN_USOCK_STATE_CANCELLING_IO 7 #define NN_USOCK_STATE_DONE 8 #define NN_USOCK_STATE_LISTENING 9 #define NN_USOCK_STATE_ACCEPTING 10 #define NN_USOCK_STATE_CANCELLING 11 #define NN_USOCK_STATE_STOPPING 12 #define NN_USOCK_STATE_STOPPING_ACCEPT 13 #define NN_USOCK_ACTION_ACCEPT 1 #define NN_USOCK_ACTION_BEING_ACCEPTED 2 #define NN_USOCK_ACTION_CANCEL 3 #define NN_USOCK_ACTION_LISTEN 4 #define NN_USOCK_ACTION_CONNECT 5 #define NN_USOCK_ACTION_ACTIVATE 6 #define NN_USOCK_ACTION_DONE 7 #define NN_USOCK_ACTION_ERROR 8 #define NN_USOCK_SRC_IN 1 #define NN_USOCK_SRC_OUT 2 /* Private functions. */ static void nn_usock_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_usock_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static int nn_usock_cancel_io (struct nn_usock *self); static void nn_usock_create_io_completion (struct nn_usock *self); DWORD nn_usock_open_pipe (struct nn_usock *self, const char *name); void nn_usock_accept_pipe (struct nn_usock *self, struct nn_usock *listener); void nn_usock_init (struct nn_usock *self, int src, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_usock_handler, nn_usock_shutdown, src, self, owner); self->state = NN_USOCK_STATE_IDLE; self->s = INVALID_SOCKET; self->isaccepted = 0; nn_worker_op_init (&self->in, NN_USOCK_SRC_IN, &self->fsm); nn_worker_op_init (&self->out, NN_USOCK_SRC_OUT, &self->fsm); self->domain = -1; self->type = -1; self->protocol = -1; /* Intialise events raised by usock. */ nn_fsm_event_init (&self->event_established); nn_fsm_event_init (&self->event_sent); nn_fsm_event_init (&self->event_received); nn_fsm_event_init (&self->event_error); /* No accepting is going on at the moment. */ self->asock = NULL; self->ainfo = NULL; /* NamedPipe-related stuff. */ memset (&self->pipename, 0, sizeof (self->pipename)); self->pipesendbuf = NULL; } void nn_usock_term (struct nn_usock *self) { nn_assert_state (self, NN_USOCK_STATE_IDLE); if (self->ainfo) nn_free (self->ainfo); if (self->pipesendbuf) nn_free (self->pipesendbuf); nn_fsm_event_term (&self->event_error); nn_fsm_event_term (&self->event_received); nn_fsm_event_term (&self->event_sent); nn_fsm_event_term (&self->event_established); nn_worker_op_term (&self->out); nn_worker_op_term (&self->in); nn_fsm_term (&self->fsm); } int nn_usock_isidle (struct nn_usock *self) { return nn_fsm_isidle (&self->fsm); } int nn_usock_start (struct nn_usock *self, int domain, int type, int protocol) { int rc; #if defined IPV6_V6ONLY DWORD only; #endif #if defined HANDLE_FLAG_INHERIT BOOL brc; #endif /* NamedPipes aren't sockets. They don't need all the socket initialisation stuff. */ if (domain != AF_UNIX) { /* Open the underlying socket. */ self->s = socket (domain, type, protocol); if (self->s == INVALID_SOCKET) return -nn_err_wsa_to_posix (WSAGetLastError ()); /* Disable inheriting the socket to the child processes. */ #if defined HANDLE_FLAG_INHERIT brc = SetHandleInformation (self->p, HANDLE_FLAG_INHERIT, 0); win_assert (brc); #endif /* IPv4 mapping for IPv6 sockets is disabled by default. Switch it on. */ #if defined IPV6_V6ONLY if (domain == AF_INET6) { only = 0; rc = setsockopt (self->s, IPPROTO_IPV6, IPV6_V6ONLY, (const char*) &only, sizeof (only)); wsa_assert (rc != SOCKET_ERROR); } #endif /* Associate the socket with a worker thread/completion port. */ nn_usock_create_io_completion (self); } /* Remember the type of the socket. */ self->domain = domain; self->type = type; self->protocol = protocol; /* Start the state machine. */ nn_fsm_start (&self->fsm); return 0; } void nn_usock_start_fd (struct nn_usock *self, int fd) { nn_assert (0); } void nn_usock_stop (struct nn_usock *self) { nn_fsm_stop (&self->fsm); } void nn_usock_swap_owner (struct nn_usock *self, struct nn_fsm_owner *owner) { nn_fsm_swap_owner (&self->fsm, owner); } int nn_usock_setsockopt (struct nn_usock *self, int level, int optname, const void *optval, size_t optlen) { int rc; /* NamedPipes aren't sockets. We can't set socket options on them. For now we'll ignore the options. */ if (self->domain == AF_UNIX) return 0; /* The socket can be modified only before it's active. */ nn_assert (self->state == NN_USOCK_STATE_STARTING || self->state == NN_USOCK_STATE_ACCEPTED); nn_assert (optlen < INT_MAX); rc = setsockopt (self->s, level, optname, (char*) optval, (int) optlen); if (nn_slow (rc == SOCKET_ERROR)) return -nn_err_wsa_to_posix (WSAGetLastError ()); return 0; } int nn_usock_bind (struct nn_usock *self, const struct sockaddr *addr, size_t addrlen) { int rc; ULONG opt; /* In the case of named pipes, let's save the address for the later use. */ if (self->domain == AF_UNIX) { if (addrlen > sizeof (struct sockaddr_un)) return -EINVAL; memcpy (&self->pipename, addr, addrlen); return 0; } /* You can set socket options only before the socket is connected. */ nn_assert_state (self, NN_USOCK_STATE_STARTING); /* On Windows, the bound port can be hijacked if SO_EXCLUSIVEADDRUSE is not set. */ opt = 1; rc = setsockopt (self->s, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (const char*) &opt, sizeof (opt)); wsa_assert (rc != SOCKET_ERROR); nn_assert (addrlen < INT_MAX); rc = bind (self->s, addr, (int) addrlen); if (nn_slow (rc == SOCKET_ERROR)) return -nn_err_wsa_to_posix (WSAGetLastError ()); return 0; } int nn_usock_listen (struct nn_usock *self, int backlog) { int rc; /* You can start listening only before the socket is connected. */ nn_assert_state (self, NN_USOCK_STATE_STARTING); /* Start listening for incoming connections. NamedPipes are already created in the listening state, so no need to do anything here. */ if (self->domain != AF_UNIX) { rc = listen (self->s, backlog); if (nn_slow (rc == SOCKET_ERROR)) return -nn_err_wsa_to_posix (WSAGetLastError ()); } /* Notify the state machine. */ nn_fsm_action (&self->fsm, NN_USOCK_ACTION_LISTEN); return 0; } void nn_usock_accept (struct nn_usock *self, struct nn_usock *listener) { int rc; BOOL brc; DWORD nbytes; /* NamedPipes have their own accepting mechanism. */ if (listener->domain == AF_UNIX) { nn_usock_accept_pipe (self, listener); return; } rc = nn_usock_start (self, listener->domain, listener->type, listener->protocol); /* TODO: EMFILE can be returned here. */ errnum_assert (rc == 0, -rc); nn_fsm_action (&listener->fsm, NN_USOCK_ACTION_ACCEPT); nn_fsm_action (&self->fsm, NN_USOCK_ACTION_BEING_ACCEPTED); /* If the memory for accept information is not yet allocated, do so. */ if (!listener->ainfo) { listener->ainfo = nn_alloc (512, "accept info"); alloc_assert (listener->ainfo); } /* Wait for the incoming connection. */ memset (&listener->in.olpd, 0, sizeof (listener->in.olpd)); brc = AcceptEx (listener->s, self->s, listener->ainfo, 0, 256, 256, &nbytes, &listener->in.olpd); /* Immediate success. */ if (nn_fast (brc == TRUE)) { nn_fsm_action (&listener->fsm, NN_USOCK_ACTION_DONE); nn_fsm_action (&self->fsm, NN_USOCK_ACTION_DONE); return; } /* We don't expect a synchronous failure at this point. */ wsa_assert (nn_slow (WSAGetLastError () == WSA_IO_PENDING)); /* Pair the two sockets. */ nn_assert (!self->asock); self->asock = listener; nn_assert (!listener->asock); listener->asock = self; /* Asynchronous accept. */ nn_worker_op_start (&listener->in, 0); } void nn_usock_activate (struct nn_usock *self) { nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ACTIVATE); } void nn_usock_connect (struct nn_usock *self, const struct sockaddr *addr, size_t addrlen) { BOOL brc; const GUID fid = WSAID_CONNECTEX; LPFN_CONNECTEX pconnectex; DWORD nbytes; DWORD winerror; /* Fail if the socket is already connected, closed or such. */ nn_assert_state (self, NN_USOCK_STATE_STARTING); /* Notify the state machine that we've started connecting. */ nn_fsm_action (&self->fsm, NN_USOCK_ACTION_CONNECT); nn_assert(addrlen < INT_MAX); memset (&self->out.olpd, 0, sizeof (self->out.olpd)); if (self->domain == AF_UNIX) { winerror = nn_usock_open_pipe (self, ((struct sockaddr_un*) addr)->sun_path); } else { /* Get the pointer to connect function. */ brc = WSAIoctl(self->s, SIO_GET_EXTENSION_FUNCTION_POINTER, (void*)&fid, sizeof(fid), (void*)&pconnectex, sizeof(pconnectex), &nbytes, NULL, NULL) == 0; wsa_assert(brc == TRUE); nn_assert(nbytes == sizeof(pconnectex)); /* Connect itself. */ brc = pconnectex(self->s, (struct sockaddr*) addr, addrlen, NULL, 0, NULL, &self->out.olpd); winerror = brc ? ERROR_SUCCESS : WSAGetLastError(); } /* Immediate success. */ if (nn_fast (winerror == ERROR_SUCCESS)) { nn_fsm_action (&self->fsm, NN_USOCK_ACTION_DONE); return; } /* Immediate error. */ if (nn_slow (winerror != WSA_IO_PENDING)) { nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ERROR); return; } /* Asynchronous connect. */ nn_worker_op_start (&self->out, 0); } void nn_usock_send (struct nn_usock *self, const struct nn_iovec *iov, int iovcnt) { int rc; BOOL brc; WSABUF wbuf [NN_USOCK_MAX_IOVCNT]; int i; size_t len; size_t idx; DWORD error; /* Make sure that the socket is actually alive. */ nn_assert_state (self, NN_USOCK_STATE_ACTIVE); /* Create a WinAPI-style iovec. */ len = 0; nn_assert (iovcnt <= NN_USOCK_MAX_IOVCNT); for (i = 0; i != iovcnt; ++i) { wbuf [i].buf = (char FAR*) iov [i].iov_base; wbuf [i].len = (u_long) iov [i].iov_len; len += iov [i].iov_len; } /* Start the send operation. */ memset (&self->out.olpd, 0, sizeof (self->out.olpd)); if (self->domain == AF_UNIX) { /* TODO: Do not copy the buffer, find an efficent way to Write multiple buffers that doesn't affect the state machine. */ nn_assert (!self->pipesendbuf); self->pipesendbuf = nn_alloc (len, "named pipe sendbuf"); idx = 0; for (i = 0; i != iovcnt; ++i) { memcpy ((char*)(self->pipesendbuf) + idx, iov [i].iov_base, iov [i].iov_len); idx += iov [i].iov_len; } brc = WriteFile (self->p, self->pipesendbuf, len, NULL, &self->out.olpd); if (nn_fast (brc || GetLastError() == ERROR_IO_PENDING)) { nn_worker_op_start (&self->out, 0); return; } error = GetLastError(); win_assert (error == ERROR_NO_DATA); self->errnum = EINVAL; nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ERROR); return; } rc = WSASend (self->s, wbuf, iovcnt, NULL, 0, &self->out.olpd, NULL); if (nn_fast (rc == 0)) { nn_worker_op_start (&self->out, 0); return; } error = WSAGetLastError(); if (nn_fast (error == WSA_IO_PENDING)) { nn_worker_op_start (&self->out, 0); return; } wsa_assert (error == WSAECONNABORTED || error == WSAECONNRESET || error == WSAENETDOWN || error == WSAENETRESET || error == WSAENOBUFS || error == WSAEWOULDBLOCK); self->errnum = nn_err_wsa_to_posix (error); nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ERROR); } void nn_usock_recv (struct nn_usock *self, void *buf, size_t len, int *fd) { int rc; BOOL brc; WSABUF wbuf; DWORD wflags; DWORD error; /* Passing file descriptors is not implemented on Windows platform. */ if (fd) *fd = -1; /* Make sure that the socket is actually alive. */ nn_assert_state (self, NN_USOCK_STATE_ACTIVE); /* Start the receive operation. */ wbuf.len = (u_long) len; wbuf.buf = (char FAR*) buf; wflags = MSG_WAITALL; memset (&self->in.olpd, 0, sizeof (self->in.olpd)); if (self->domain == AF_UNIX) { brc = ReadFile(self->p, buf, len, NULL, &self->in.olpd); error = brc ? ERROR_SUCCESS : GetLastError(); } else { rc = WSARecv (self->s, &wbuf, 1, NULL, &wflags, &self->in.olpd, NULL); error = (rc == 0) ? ERROR_SUCCESS : WSAGetLastError (); } if (nn_fast (error == ERROR_SUCCESS)) { nn_worker_op_start (&self->in, 1); return; } if (nn_fast (error == WSA_IO_PENDING)) { nn_worker_op_start (&self->in, 1); return; } if (error == WSAECONNABORTED || error == WSAECONNRESET || error == WSAENETDOWN || error == WSAENETRESET || error == WSAETIMEDOUT || error == WSAEWOULDBLOCK || error == ERROR_PIPE_NOT_CONNECTED || error == ERROR_BROKEN_PIPE) { nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ERROR); return; } wsa_assert (0); } static void nn_usock_create_io_completion (struct nn_usock *self) { struct nn_worker *worker; HANDLE cp; /* Associate the socket with a worker thread/completion port. */ worker = nn_fsm_choose_worker (&self->fsm); cp = CreateIoCompletionPort ( self->p, nn_worker_getcp(worker), (ULONG_PTR) NULL, 0); nn_assert(cp); } static void nn_usock_create_pipe (struct nn_usock *self, const char *name) { char fullname [256]; /* First, create a fully qualified name for the named pipe. */ _snprintf(fullname, sizeof (fullname), "\\\\.\\pipe\\%s", name); /* TODO: Expose custom nOutBufferSize, nInBufferSize, nDefaultTimeOut, lpSecurityAttributes */ self->p = CreateNamedPipeA ( (char*) fullname, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS, PIPE_UNLIMITED_INSTANCES, 4096, 4096, 0, NULL); /* TODO: How to properly handle self->p == INVALID_HANDLE_VALUE? */ win_assert (self->p != INVALID_HANDLE_VALUE); self->isaccepted = 1; nn_usock_create_io_completion (self); } DWORD nn_usock_open_pipe (struct nn_usock *self, const char *name) { char fullname [256]; DWORD winerror; DWORD mode; BOOL brc; /* First, create a fully qualified name for the named pipe. */ _snprintf(fullname, sizeof (fullname), "\\\\.\\pipe\\%s", name); /* TODO: Expose a way to pass lpSecurityAttributes */ self->p = CreateFileA ( fullname, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED, NULL); if (self->p == INVALID_HANDLE_VALUE) return GetLastError (); mode = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT; brc = SetNamedPipeHandleState ( self->p, &mode, NULL, NULL); if (!brc) { CloseHandle (self->p); self->p = INVALID_HANDLE_VALUE; return GetLastError (); } self->isaccepted = 0; nn_usock_create_io_completion (self); winerror = GetLastError (); if (winerror != ERROR_SUCCESS && winerror != ERROR_ALREADY_EXISTS) return winerror; return ERROR_SUCCESS; } void nn_usock_accept_pipe (struct nn_usock *self, struct nn_usock *listener) { int rc; BOOL brc; DWORD winerror; /* TODO: EMFILE can be returned here. */ rc = nn_usock_start (self, listener->domain, listener->type, listener->protocol); errnum_assert(rc == 0, -rc); nn_fsm_action(&listener->fsm, NN_USOCK_ACTION_ACCEPT); nn_fsm_action(&self->fsm, NN_USOCK_ACTION_BEING_ACCEPTED); /* If the memory for accept information is not yet allocated, do so now. */ if (!listener->ainfo) { listener->ainfo = nn_alloc (512, "accept info"); alloc_assert (listener->ainfo); } /* Wait for the incoming connection. */ memset (&listener->in.olpd, 0, sizeof(listener->in.olpd)); nn_usock_create_pipe (self, listener->pipename.sun_path); brc = ConnectNamedPipe (self->p, (LPOVERLAPPED) &listener->in.olpd); /* TODO: Can this function possibly succeed? */ nn_assert (brc == 0); winerror = GetLastError(); /* Immediate success. */ if (nn_fast (winerror == ERROR_PIPE_CONNECTED)) { nn_fsm_action (&listener->fsm, NN_USOCK_ACTION_DONE); nn_fsm_action (&self->fsm, NN_USOCK_ACTION_DONE); return; } /* We don't expect a synchronous failure at this point. */ wsa_assert (nn_slow (winerror == WSA_IO_PENDING)); /* Pair the two sockets. */ nn_assert (!self->asock); self->asock = listener; nn_assert (!listener->asock); listener->asock = self; /* Asynchronous accept. */ nn_worker_op_start (&listener->in, 0); } static void nn_usock_close (struct nn_usock *self) { int rc; BOOL brc; if (self->domain == AF_UNIX) { if (self->p == INVALID_HANDLE_VALUE) return; if (self->isaccepted) DisconnectNamedPipe(self->p); brc = CloseHandle (self->p); self->p = INVALID_HANDLE_VALUE; win_assert (brc); } else { rc = closesocket (self->s); self->s = INVALID_SOCKET; wsa_assert (rc == 0); } } static void nn_usock_shutdown (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_usock *usock; usock = nn_cont (self, struct nn_usock, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { /* Socket in ACCEPTING state cannot be closed. Stop the socket being accepted first. */ nn_assert (usock->state != NN_USOCK_STATE_ACCEPTING); /* Synchronous stop. */ if (usock->state == NN_USOCK_STATE_IDLE) goto finish3; if (usock->state == NN_USOCK_STATE_DONE) goto finish2; if (usock->state == NN_USOCK_STATE_STARTING || usock->state == NN_USOCK_STATE_ACCEPTED || usock->state == NN_USOCK_STATE_LISTENING) goto finish1; /* When socket that's being accepted is asked to stop, we have to ask the listener socket to stop accepting first. */ if (usock->state == NN_USOCK_STATE_BEING_ACCEPTED) { nn_fsm_action (&usock->asock->fsm, NN_USOCK_ACTION_CANCEL); usock->state = NN_USOCK_STATE_STOPPING_ACCEPT; return; } /* If we were already in the process of cancelling overlapped operations, we don't have to do anything. Continue waiting till cancelling is finished. */ if (usock->state == NN_USOCK_STATE_CANCELLING_IO) { usock->state = NN_USOCK_STATE_STOPPING; return; } /* Notify our parent that pipe socket is shutting down */ nn_fsm_raise (&usock->fsm, &usock->event_error, NN_USOCK_SHUTDOWN); /* In all remaining states we'll simply cancel all overlapped operations. */ if (nn_usock_cancel_io (usock) == 0) goto finish1; usock->state = NN_USOCK_STATE_STOPPING; return; } if (nn_slow (usock->state == NN_USOCK_STATE_STOPPING_ACCEPT)) { nn_assert (src == NN_FSM_ACTION && type == NN_USOCK_ACTION_DONE); goto finish1; } if (nn_slow (usock->state == NN_USOCK_STATE_STOPPING)) { if (!nn_worker_op_isidle (&usock->in) || !nn_worker_op_isidle (&usock->out)) return; finish1: nn_usock_close(usock); finish2: usock->state = NN_USOCK_STATE_IDLE; nn_fsm_stopped (&usock->fsm, NN_USOCK_STOPPED); finish3: return; } nn_fsm_bad_state(usock->state, src, type); } static void nn_usock_handler (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_usock *usock; usock = nn_cont (self, struct nn_usock, fsm); switch (usock->state) { /*****************************************************************************/ /* IDLE state. */ /*****************************************************************************/ case NN_USOCK_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: usock->state = NN_USOCK_STATE_STARTING; return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /*****************************************************************************/ /* STARTING state. */ /*****************************************************************************/ case NN_USOCK_STATE_STARTING: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_LISTEN: usock->state = NN_USOCK_STATE_LISTENING; return; case NN_USOCK_ACTION_CONNECT: usock->state = NN_USOCK_STATE_CONNECTING; return; case NN_USOCK_ACTION_BEING_ACCEPTED: usock->state = NN_USOCK_STATE_BEING_ACCEPTED; return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /*****************************************************************************/ /* BEING_ACCEPTED state. */ /*****************************************************************************/ case NN_USOCK_STATE_BEING_ACCEPTED: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_DONE: usock->state = NN_USOCK_STATE_ACCEPTED; nn_fsm_raise (&usock->fsm, &usock->event_established, NN_USOCK_ACCEPTED); return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /*****************************************************************************/ /* ACCEPTED state. */ /*****************************************************************************/ case NN_USOCK_STATE_ACCEPTED: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_ACTIVATE: usock->state = NN_USOCK_STATE_ACTIVE; return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /*****************************************************************************/ /* CONNECTING state. */ /*****************************************************************************/ case NN_USOCK_STATE_CONNECTING: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_DONE: usock->state = NN_USOCK_STATE_ACTIVE; nn_fsm_raise (&usock->fsm, &usock->event_established, NN_USOCK_CONNECTED); return; case NN_USOCK_ACTION_ERROR: nn_usock_close(usock); usock->state = NN_USOCK_STATE_DONE; nn_fsm_raise (&usock->fsm, &usock->event_error, NN_USOCK_ERROR); return; default: nn_fsm_bad_action (usock->state, src, type); } case NN_USOCK_SRC_OUT: switch (type) { case NN_WORKER_OP_DONE: usock->state = NN_USOCK_STATE_ACTIVE; nn_fsm_raise (&usock->fsm, &usock->event_established, NN_USOCK_CONNECTED); return; case NN_WORKER_OP_ERROR: nn_usock_close(usock); usock->state = NN_USOCK_STATE_DONE; nn_fsm_raise (&usock->fsm, &usock->event_error, NN_USOCK_ERROR); return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /*****************************************************************************/ /* ACTIVE state. */ /*****************************************************************************/ case NN_USOCK_STATE_ACTIVE: switch (src) { case NN_USOCK_SRC_IN: switch (type) { case NN_WORKER_OP_DONE: nn_fsm_raise (&usock->fsm, &usock->event_received, NN_USOCK_RECEIVED); return; case NN_WORKER_OP_ERROR: if (nn_usock_cancel_io (usock) == 0) { nn_fsm_raise(&usock->fsm, &usock->event_error, NN_USOCK_ERROR); nn_usock_close (usock); usock->state = NN_USOCK_STATE_DONE; return; } usock->state = NN_USOCK_STATE_CANCELLING_IO; return; default: nn_fsm_bad_action (usock->state, src, type); } case NN_USOCK_SRC_OUT: switch (type) { case NN_WORKER_OP_DONE: if (usock->pipesendbuf) { nn_free(usock->pipesendbuf); usock->pipesendbuf = NULL; } nn_fsm_raise (&usock->fsm, &usock->event_sent, NN_USOCK_SENT); return; case NN_WORKER_OP_ERROR: if (nn_usock_cancel_io (usock) == 0) { nn_fsm_raise(&usock->fsm, &usock->event_error, NN_USOCK_ERROR); nn_usock_close(usock); usock->state = NN_USOCK_STATE_DONE; return; } usock->state = NN_USOCK_STATE_CANCELLING_IO; return; default: nn_fsm_bad_action (usock->state, src, type); } case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_ERROR: if (nn_usock_cancel_io (usock) == 0) { nn_fsm_raise(&usock->fsm, &usock->event_error, NN_USOCK_SHUTDOWN); nn_usock_close(usock); usock->state = NN_USOCK_STATE_DONE; return; } usock->state = NN_USOCK_STATE_CANCELLING_IO; return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /*****************************************************************************/ /* CANCELLING_IO state. */ /*****************************************************************************/ case NN_USOCK_STATE_CANCELLING_IO: switch (src) { case NN_USOCK_SRC_IN: case NN_USOCK_SRC_OUT: if (!nn_worker_op_isidle (&usock->in) || !nn_worker_op_isidle (&usock->out)) return; nn_fsm_raise(&usock->fsm, &usock->event_error, NN_USOCK_SHUTDOWN); nn_usock_close(usock); usock->state = NN_USOCK_STATE_DONE; return; default: nn_fsm_bad_source (usock->state, src, type); } /*****************************************************************************/ /* DONE state. */ /*****************************************************************************/ case NN_USOCK_STATE_DONE: nn_fsm_bad_source (usock->state, src, type); /*****************************************************************************/ /* LISTENING state. */ /*****************************************************************************/ case NN_USOCK_STATE_LISTENING: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_ACCEPT: usock->state = NN_USOCK_STATE_ACCEPTING; return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /*****************************************************************************/ /* ACCEPTING state. */ /*****************************************************************************/ case NN_USOCK_STATE_ACCEPTING: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_USOCK_ACTION_DONE: usock->state = NN_USOCK_STATE_LISTENING; return; case NN_USOCK_ACTION_CANCEL: if (usock->p == INVALID_HANDLE_VALUE && usock->asock != NULL && usock->domain == AF_UNIX) { usock->p = usock->asock->p; nn_usock_cancel_io (usock); usock->p = INVALID_HANDLE_VALUE; } else { nn_usock_cancel_io(usock); } usock->state = NN_USOCK_STATE_CANCELLING; return; default: nn_fsm_bad_action (usock->state, src, type); } case NN_USOCK_SRC_IN: switch (type) { case NN_WORKER_OP_DONE: /* Adjust the new usock object. */ usock->asock->state = NN_USOCK_STATE_ACCEPTED; /* Notify the user that connection was accepted. */ nn_fsm_raise (&usock->asock->fsm, &usock->asock->event_established, NN_USOCK_ACCEPTED); /* Disassociate the listener socket from the accepted socket. */ usock->asock->asock = NULL; usock->asock = NULL; /* Wait till the user starts accepting once again. */ usock->state = NN_USOCK_STATE_LISTENING; return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /*****************************************************************************/ /* CANCELLING state. */ /*****************************************************************************/ case NN_USOCK_STATE_CANCELLING: switch (src) { case NN_USOCK_SRC_IN: switch (type) { case NN_WORKER_OP_DONE: case NN_WORKER_OP_ERROR: /* TODO: The socket being accepted should be closed here. */ usock->state = NN_USOCK_STATE_LISTENING; /* Notify the accepted socket that it was stopped. */ nn_fsm_action (&usock->asock->fsm, NN_USOCK_ACTION_DONE); return; default: nn_fsm_bad_action (usock->state, src, type); } default: nn_fsm_bad_source (usock->state, src, type); } /*****************************************************************************/ /* Invalid state. */ /*****************************************************************************/ default: nn_fsm_bad_state (usock->state, src, type); } } /*****************************************************************************/ /* State machine actions. */ /*****************************************************************************/ /* Returns 0 if there's nothing to cancel or 1 otherwise. */ static int nn_usock_cancel_io (struct nn_usock *self) { int rc; BOOL brc; /* For some reason simple CancelIo doesn't seem to work here. We have to use CancelIoEx instead. */ rc = 0; if (!nn_worker_op_isidle (&self->in)) { brc = CancelIoEx (self->p, &self->in.olpd); win_assert (brc || GetLastError () == ERROR_NOT_FOUND); rc = 1; } if (!nn_worker_op_isidle (&self->out)) { brc = CancelIoEx (self->p, &self->out.olpd); win_assert (brc || GetLastError () == ERROR_NOT_FOUND); rc = 1; } return rc; } nanomsg-0.8-beta/src/aio/worker.h0000664000175000017500000000453012623652600017665 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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. */ #ifndef NN_WORKER_INCLUDED #define NN_WORKER_INCLUDED #include "fsm.h" #include "timerset.h" #if defined NN_HAVE_WINDOWS #include "worker_win.h" #else #include "worker_posix.h" #endif #define NN_WORKER_TIMER_TIMEOUT 1 struct nn_worker_timer { struct nn_fsm *owner; struct nn_timerset_hndl hndl; }; void nn_worker_timer_init (struct nn_worker_timer *self, struct nn_fsm *owner); void nn_worker_timer_term (struct nn_worker_timer *self); int nn_worker_timer_isactive (struct nn_worker_timer *self); #define NN_WORKER_TASK_EXECUTE 1 struct nn_worker_task; void nn_worker_task_init (struct nn_worker_task *self, int src, struct nn_fsm *owner); void nn_worker_task_term (struct nn_worker_task *self); struct nn_worker; int nn_worker_init (struct nn_worker *self); void nn_worker_term (struct nn_worker *self); void nn_worker_execute (struct nn_worker *self, struct nn_worker_task *task); void nn_worker_cancel (struct nn_worker *self, struct nn_worker_task *task); void nn_worker_add_timer (struct nn_worker *self, int timeout, struct nn_worker_timer *timer); void nn_worker_rm_timer (struct nn_worker *self, struct nn_worker_timer *timer); #endif nanomsg-0.8-beta/src/aio/worker.c0000664000175000017500000000314512623652600017661 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "worker.h" #if defined NN_HAVE_WINDOWS #include "worker_win.inc" #else #include "worker_posix.inc" #endif void nn_worker_timer_init (struct nn_worker_timer *self, struct nn_fsm *owner) { self->owner = owner; nn_timerset_hndl_init (&self->hndl); } void nn_worker_timer_term (struct nn_worker_timer *self) { nn_timerset_hndl_term (&self->hndl); } int nn_worker_timer_isactive (struct nn_worker_timer *self) { return nn_timerset_hndl_isactive (&self->hndl); } nanomsg-0.8-beta/src/aio/worker_posix.h0000664000175000017500000000470612623652600021114 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "../utils/queue.h" #include "../utils/mutex.h" #include "../utils/thread.h" #include "../utils/efd.h" #include "poller.h" #define NN_WORKER_FD_IN NN_POLLER_IN #define NN_WORKER_FD_OUT NN_POLLER_OUT #define NN_WORKER_FD_ERR NN_POLLER_ERR struct nn_worker_fd { int src; struct nn_fsm *owner; struct nn_poller_hndl hndl; }; void nn_worker_fd_init (struct nn_worker_fd *self, int src, struct nn_fsm *owner); void nn_worker_fd_term (struct nn_worker_fd *self); struct nn_worker_task { int src; struct nn_fsm *owner; struct nn_queue_item item; }; struct nn_worker { struct nn_mutex sync; struct nn_queue tasks; struct nn_queue_item stop; struct nn_efd efd; struct nn_poller poller; struct nn_poller_hndl efd_hndl; struct nn_timerset timerset; struct nn_thread thread; }; void nn_worker_add_fd (struct nn_worker *self, int s, struct nn_worker_fd *fd); void nn_worker_rm_fd(struct nn_worker *self, struct nn_worker_fd *fd); void nn_worker_set_in (struct nn_worker *self, struct nn_worker_fd *fd); void nn_worker_reset_in (struct nn_worker *self, struct nn_worker_fd *fd); void nn_worker_set_out (struct nn_worker *self, struct nn_worker_fd *fd); void nn_worker_reset_out (struct nn_worker *self, struct nn_worker_fd *fd); nanomsg-0.8-beta/src/aio/worker_posix.inc0000664000175000017500000002012612623652600021430 0ustar00travistravis00000000000000/* Copyright (c) 2013-2014 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. All rights reserved. Copyright 2015 Garrett D'Amore 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 "ctx.h" #include "../utils/err.h" #include "../utils/fast.h" #include "../utils/cont.h" #include "../utils/attr.h" #include "../utils/queue.h" /* Private functions. */ static void nn_worker_routine (void *arg); void nn_worker_fd_init (struct nn_worker_fd *self, int src, struct nn_fsm *owner) { self->src = src; self->owner = owner; } void nn_worker_fd_term (NN_UNUSED struct nn_worker_fd *self) { } void nn_worker_add_fd (struct nn_worker *self, int s, struct nn_worker_fd *fd) { nn_poller_add (&((struct nn_worker*) self)->poller, s, &fd->hndl); } void nn_worker_rm_fd (struct nn_worker *self, struct nn_worker_fd *fd) { nn_poller_rm (&((struct nn_worker*) self)->poller, &fd->hndl); } void nn_worker_set_in (struct nn_worker *self, struct nn_worker_fd *fd) { nn_poller_set_in (&((struct nn_worker*) self)->poller, &fd->hndl); } void nn_worker_reset_in (struct nn_worker *self, struct nn_worker_fd *fd) { nn_poller_reset_in (&((struct nn_worker*) self)->poller, &fd->hndl); } void nn_worker_set_out (struct nn_worker *self, struct nn_worker_fd *fd) { nn_poller_set_out (&((struct nn_worker*) self)->poller, &fd->hndl); } void nn_worker_reset_out (struct nn_worker *self, struct nn_worker_fd *fd) { nn_poller_reset_out (&((struct nn_worker*) self)->poller, &fd->hndl); } void nn_worker_add_timer (struct nn_worker *self, int timeout, struct nn_worker_timer *timer) { nn_timerset_add (&((struct nn_worker*) self)->timerset, timeout, &timer->hndl); } void nn_worker_rm_timer (struct nn_worker *self, struct nn_worker_timer *timer) { nn_timerset_rm (&((struct nn_worker*) self)->timerset, &timer->hndl); } void nn_worker_task_init (struct nn_worker_task *self, int src, struct nn_fsm *owner) { self->src = src; self->owner = owner; nn_queue_item_init (&self->item); } void nn_worker_task_term (struct nn_worker_task *self) { nn_queue_item_term (&self->item); } int nn_worker_init (struct nn_worker *self) { int rc; rc = nn_efd_init (&self->efd); if (rc < 0) return rc; nn_mutex_init (&self->sync); nn_queue_init (&self->tasks); nn_queue_item_init (&self->stop); nn_poller_init (&self->poller); nn_poller_add (&self->poller, nn_efd_getfd (&self->efd), &self->efd_hndl); nn_poller_set_in (&self->poller, &self->efd_hndl); nn_timerset_init (&self->timerset); nn_thread_init (&self->thread, nn_worker_routine, self); return 0; } void nn_worker_term (struct nn_worker *self) { /* Ask worker thread to terminate. */ nn_mutex_lock (&self->sync); nn_queue_push (&self->tasks, &self->stop); nn_efd_signal (&self->efd); nn_mutex_unlock (&self->sync); /* Wait till worker thread terminates. */ nn_thread_term (&self->thread); /* Clean up. */ nn_timerset_term (&self->timerset); nn_poller_term (&self->poller); nn_efd_term (&self->efd); nn_queue_item_term (&self->stop); nn_queue_term (&self->tasks); nn_mutex_term (&self->sync); } void nn_worker_execute (struct nn_worker *self, struct nn_worker_task *task) { nn_mutex_lock (&self->sync); nn_queue_push (&self->tasks, &task->item); nn_efd_signal (&self->efd); nn_mutex_unlock (&self->sync); } void nn_worker_cancel (struct nn_worker *self, struct nn_worker_task *task) { nn_mutex_lock (&self->sync); nn_queue_remove (&self->tasks, &task->item); nn_mutex_unlock (&self->sync); } static void nn_worker_routine (void *arg) { int rc; struct nn_worker *self; int pevent; struct nn_poller_hndl *phndl; struct nn_timerset_hndl *thndl; struct nn_queue tasks; struct nn_queue_item *item; struct nn_worker_task *task; struct nn_worker_fd *fd; struct nn_worker_timer *timer; self = (struct nn_worker*) arg; /* Infinite loop. It will be interrupted only when the object is shut down. */ while (1) { /* Wait for new events and/or timeouts. */ rc = nn_poller_wait (&self->poller, nn_timerset_timeout (&self->timerset)); errnum_assert (rc == 0, -rc); /* Process all expired timers. */ while (1) { rc = nn_timerset_event (&self->timerset, &thndl); if (rc == -EAGAIN) break; errnum_assert (rc == 0, -rc); timer = nn_cont (thndl, struct nn_worker_timer, hndl); nn_ctx_enter (timer->owner->ctx); nn_fsm_feed (timer->owner, -1, NN_WORKER_TIMER_TIMEOUT, timer); nn_ctx_leave (timer->owner->ctx); } /* Process all events from the poller. */ while (1) { /* Get next poller event, such as IN or OUT. */ rc = nn_poller_event (&self->poller, &pevent, &phndl); if (nn_slow (rc == -EAGAIN)) break; /* If there are any new incoming worker tasks, process them. */ if (phndl == &self->efd_hndl) { nn_assert (pevent == NN_POLLER_IN); /* Make a local copy of the task queue. This way the application threads are not blocked and can post new tasks while the existing tasks are being processed. Also, new tasks can be posted from within task handlers. */ nn_mutex_lock (&self->sync); nn_efd_unsignal (&self->efd); memcpy (&tasks, &self->tasks, sizeof (tasks)); nn_queue_init (&self->tasks); nn_mutex_unlock (&self->sync); while (1) { /* Next worker task. */ item = nn_queue_pop (&tasks); if (nn_slow (!item)) break; /* If the worker thread is asked to stop, do so. */ if (nn_slow (item == &self->stop)) { /* Make sure we remove all the other workers from the queue, because we're not doing anything with them. */ while (nn_queue_pop (&tasks) != NULL) { continue; } nn_queue_term (&tasks); return; } /* It's a user-defined task. Notify the user that it has arrived in the worker thread. */ task = nn_cont (item, struct nn_worker_task, item); nn_ctx_enter (task->owner->ctx); nn_fsm_feed (task->owner, task->src, NN_WORKER_TASK_EXECUTE, task); nn_ctx_leave (task->owner->ctx); } nn_queue_term (&tasks); continue; } /* It's a true I/O event. Invoke the handler. */ fd = nn_cont (phndl, struct nn_worker_fd, hndl); nn_ctx_enter (fd->owner->ctx); nn_fsm_feed (fd->owner, fd->src, pevent, fd); nn_ctx_leave (fd->owner->ctx); } } } nanomsg-0.8-beta/src/aio/worker_win.h0000664000175000017500000000422612623652600020544 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "fsm.h" #include "timerset.h" #include "../utils/win.h" #include "../utils/thread.h" struct nn_worker_task { int src; struct nn_fsm *owner; }; #define NN_WORKER_OP_DONE 1 #define NN_WORKER_OP_ERROR 2 struct nn_worker_op { int src; struct nn_fsm *owner; int state; /* This structure is to be used by the user, not nn_worker_op itself. Actual usage is specific to the asynchronous operation in question. */ OVERLAPPED olpd; }; void nn_worker_op_init (struct nn_worker_op *self, int src, struct nn_fsm *owner); void nn_worker_op_term (struct nn_worker_op *self); /* Call this function when asynchronous operation is started. If 'zeroiserror' is set to 1, zero bytes transferred will be treated as an error. */ void nn_worker_op_start (struct nn_worker_op *self, int zeroiserror); int nn_worker_op_isidle (struct nn_worker_op *self); struct nn_worker { HANDLE cp; struct nn_timerset timerset; struct nn_thread thread; }; HANDLE nn_worker_getcp (struct nn_worker *self); nanomsg-0.8-beta/src/aio/worker_win.inc0000664000175000017500000001563112623652600021070 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "ctx.h" #include "usock.h" #include "../utils/err.h" #include "../utils/cont.h" #include "../utils/fast.h" #define NN_WORKER_MAX_EVENTS 32 #define NN_WORKER_OP_STATE_IDLE 1 #define NN_WORKER_OP_STATE_ACTIVE 2 #define NN_WORKER_OP_STATE_ACTIVE_ZEROISERROR 3 /* The value of this variable is irrelevant. It's used only as a placeholder for the address that is used as the 'stop' event ID. */ const int nn_worker_stop = 0; /* Private functions. */ static void nn_worker_routine (void *arg); void nn_worker_task_init (struct nn_worker_task *self, int src, struct nn_fsm *owner) { self->src = src; self->owner = owner; } void nn_worker_task_term (struct nn_worker_task *self) { } void nn_worker_op_init (struct nn_worker_op *self, int src, struct nn_fsm *owner) { self->src = src; self->owner = owner; self->state = NN_WORKER_OP_STATE_IDLE; } void nn_worker_op_term (struct nn_worker_op *self) { nn_assert_state (self, NN_WORKER_OP_STATE_IDLE); } void nn_worker_op_start (struct nn_worker_op *self, int zeroiserror) { nn_assert_state (self, NN_WORKER_OP_STATE_IDLE); self->state = zeroiserror ? NN_WORKER_OP_STATE_ACTIVE_ZEROISERROR : NN_WORKER_OP_STATE_ACTIVE; } int nn_worker_op_isidle (struct nn_worker_op *self) { return self->state == NN_WORKER_OP_STATE_IDLE ? 1 : 0; } int nn_worker_init (struct nn_worker *self) { self->cp = CreateIoCompletionPort (INVALID_HANDLE_VALUE, NULL, 0, 0); win_assert (self->cp); nn_timerset_init (&self->timerset); nn_thread_init (&self->thread, nn_worker_routine, self); return 0; } void nn_worker_term (struct nn_worker *self) { BOOL brc; /* Ask worker thread to terminate. */ brc = PostQueuedCompletionStatus (self->cp, 0, (ULONG_PTR) &nn_worker_stop, NULL); win_assert (brc); /* Wait till worker thread terminates. */ nn_thread_term (&self->thread); nn_timerset_term (&self->timerset); brc = CloseHandle (self->cp); win_assert (brc); } void nn_worker_execute (struct nn_worker *self, struct nn_worker_task *task) { BOOL brc; brc = PostQueuedCompletionStatus (self->cp, 0, (ULONG_PTR) task, NULL); win_assert (brc); } void nn_worker_add_timer (struct nn_worker *self, int timeout, struct nn_worker_timer *timer) { nn_timerset_add (&((struct nn_worker*) self)->timerset, timeout, &timer->hndl); } void nn_worker_rm_timer (struct nn_worker *self, struct nn_worker_timer *timer) { nn_timerset_rm (&((struct nn_worker*) self)->timerset, &timer->hndl); } HANDLE nn_worker_getcp (struct nn_worker *self) { return self->cp; } static void nn_worker_routine (void *arg) { int rc; BOOL brc; struct nn_worker *self; int timeout; ULONG count; ULONG i; struct nn_timerset_hndl *thndl; struct nn_worker_timer *timer; struct nn_worker_task *task; struct nn_worker_op *op; OVERLAPPED_ENTRY entries [NN_WORKER_MAX_EVENTS]; self = (struct nn_worker*) arg; while (1) { /* Process all expired timers. */ while (1) { rc = nn_timerset_event (&self->timerset, &thndl); if (nn_fast (rc == -EAGAIN)) break; errnum_assert (rc == 0, -rc); timer = nn_cont (thndl, struct nn_worker_timer, hndl); nn_ctx_enter (timer->owner->ctx); nn_fsm_feed (timer->owner, -1, NN_WORKER_TIMER_TIMEOUT, timer); nn_ctx_leave (timer->owner->ctx); } /* Compute the time interval till next timer expiration. */ timeout = nn_timerset_timeout (&self->timerset); /* Wait for new events and/or timeouts. */ brc = GetQueuedCompletionStatusEx (self->cp, entries, NN_WORKER_MAX_EVENTS, &count, timeout < 0 ? INFINITE : timeout, FALSE); if (nn_slow (!brc && GetLastError () == WAIT_TIMEOUT)) continue; win_assert (brc); for (i = 0; i != count; ++i) { /* Process I/O completion events. */ if (nn_fast (entries [i].lpOverlapped)) { op = nn_cont (entries [i].lpOverlapped, struct nn_worker_op, olpd); /* The 'Internal' field is actually an NTSTATUS. Report success and error. Ignore warnings and informational messages.*/ rc = entries [i].Internal & 0xc0000000; switch (rc) { case 0x00000000: rc = NN_WORKER_OP_DONE; break; case 0xc0000000: rc = NN_WORKER_OP_ERROR; break; default: continue; } /* Raise the completion event. */ nn_ctx_enter (op->owner->ctx); nn_assert (op->state != NN_WORKER_OP_STATE_IDLE); if (rc != NN_WORKER_OP_ERROR && op->state == NN_WORKER_OP_STATE_ACTIVE_ZEROISERROR && entries [i].dwNumberOfBytesTransferred == 0) rc = NN_WORKER_OP_ERROR; op->state = NN_WORKER_OP_STATE_IDLE; nn_fsm_feed (op->owner, op->src, rc, op); nn_ctx_leave (op->owner->ctx); continue; } /* Worker thread shutdown is requested. */ if (nn_slow (entries [i].lpCompletionKey == (ULONG_PTR) &nn_worker_stop)) return; /* Process tasks. */ task = (struct nn_worker_task*) entries [i].lpCompletionKey; nn_ctx_enter (task->owner->ctx); nn_fsm_feed (task->owner, task->src, NN_WORKER_TASK_EXECUTE, task); nn_ctx_leave (task->owner->ctx); } } } nanomsg-0.8-beta/src/core/0000775000175000017500000000000012623652617016371 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/core/ep.h0000664000175000017500000000447112623652600017144 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef NN_EP_INCLUDED #define NN_EP_INCLUDED #include "../transport.h" #include "../aio/fsm.h" #include "../utils/list.h" /* Events generated by the nn_ep object. */ #define NN_EP_STOPPED 1 struct nn_ep { struct nn_fsm fsm; int state; struct nn_epbase *epbase; struct nn_sock *sock; struct nn_ep_options options; int eid; struct nn_list_item item; char addr [NN_SOCKADDR_MAX + 1]; /* Error state for endpoint */ int last_errno; }; int nn_ep_init (struct nn_ep *self, int src, struct nn_sock *sock, int eid, struct nn_transport *transport, int bind, const char *addr); void nn_ep_term (struct nn_ep *self); void nn_ep_start (struct nn_ep *self); void nn_ep_stop (struct nn_ep *self); void nn_ep_stopped (struct nn_ep *self); struct nn_ctx *nn_ep_getctx (struct nn_ep *self); const char *nn_ep_getaddr (struct nn_ep *self); void nn_ep_getopt (struct nn_ep *self, int level, int option, void *optval, size_t *optvallen); int nn_ep_ispeer (struct nn_ep *self, int socktype); void nn_ep_set_error(struct nn_ep *self, int errnum); void nn_ep_clear_error(struct nn_ep *self); void nn_ep_stat_increment(struct nn_ep *self, int name, int increment); #endif nanomsg-0.8-beta/src/core/ep.c0000664000175000017500000001547612623652600017146 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "../transport.h" #include "ep.h" #include "sock.h" #include "../utils/err.h" #include "../utils/cont.h" #include "../utils/fast.h" #include "../utils/attr.h" #include #define NN_EP_STATE_IDLE 1 #define NN_EP_STATE_ACTIVE 2 #define NN_EP_STATE_STOPPING 3 #define NN_EP_ACTION_STOPPED 1 /* Private functions. */ static void nn_ep_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_ep_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); int nn_ep_init (struct nn_ep *self, int src, struct nn_sock *sock, int eid, struct nn_transport *transport, int bind, const char *addr) { int rc; nn_fsm_init (&self->fsm, nn_ep_handler, nn_ep_shutdown, src, self, &sock->fsm); self->state = NN_EP_STATE_IDLE; self->epbase = NULL; self->sock = sock; self->eid = eid; self->last_errno = 0; nn_list_item_init (&self->item); memcpy (&self->options, &sock->ep_template, sizeof(struct nn_ep_options)); /* Store the textual form of the address. */ nn_assert (strlen (addr) <= NN_SOCKADDR_MAX); strcpy (self->addr, addr); /* Create transport-specific part of the endpoint. */ if (bind) rc = transport->bind ((void*) self, &self->epbase); else rc = transport->connect ((void*) self, &self->epbase); /* Endpoint creation failed. */ if (rc < 0) { nn_list_item_term (&self->item); nn_fsm_term (&self->fsm); return rc; } return 0; } void nn_ep_term (struct nn_ep *self) { nn_assert_state (self, NN_EP_STATE_IDLE); self->epbase->vfptr->destroy (self->epbase); nn_list_item_term (&self->item); nn_fsm_term (&self->fsm); } void nn_ep_start (struct nn_ep *self) { nn_fsm_start (&self->fsm); } void nn_ep_stop (struct nn_ep *self) { nn_fsm_stop (&self->fsm); } void nn_ep_stopped (struct nn_ep *self) { /* TODO: Do the following in a more sane way. */ self->fsm.stopped.fsm = &self->fsm; self->fsm.stopped.src = NN_FSM_ACTION; self->fsm.stopped.srcptr = NULL; self->fsm.stopped.type = NN_EP_ACTION_STOPPED; nn_ctx_raise (self->fsm.ctx, &self->fsm.stopped); } struct nn_ctx *nn_ep_getctx (struct nn_ep *self) { return nn_sock_getctx (self->sock); } const char *nn_ep_getaddr (struct nn_ep *self) { return self->addr; } void nn_ep_getopt (struct nn_ep *self, int level, int option, void *optval, size_t *optvallen) { int rc; rc = nn_sock_getopt_inner (self->sock, level, option, optval, optvallen); errnum_assert (rc == 0, -rc); } int nn_ep_ispeer (struct nn_ep *self, int socktype) { return nn_sock_ispeer (self->sock, socktype); } static void nn_ep_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_ep *ep; ep = nn_cont (self, struct nn_ep, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { ep->epbase->vfptr->stop (ep->epbase); ep->state = NN_EP_STATE_STOPPING; return; } if (nn_slow (ep->state == NN_EP_STATE_STOPPING)) { if (src != NN_FSM_ACTION || type != NN_EP_ACTION_STOPPED) return; ep->state = NN_EP_STATE_IDLE; nn_fsm_stopped (&ep->fsm, NN_EP_STOPPED); return; } nn_fsm_bad_state (ep->state, src, type); } static void nn_ep_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_ep *ep; ep = nn_cont (self, struct nn_ep, fsm); switch (ep->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_EP_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: ep->state = NN_EP_STATE_ACTIVE; return; default: nn_fsm_bad_action (ep->state, src, type); } default: nn_fsm_bad_source (ep->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /* We don't expect any events in this state. The only thing that can be done */ /* is closing the endpoint. */ /******************************************************************************/ case NN_EP_STATE_ACTIVE: nn_fsm_bad_source (ep->state, src, type); /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (ep->state, src, type); } } void nn_ep_set_error(struct nn_ep *self, int errnum) { if (self->last_errno == errnum) /* Error is still there, no need to report it again */ return; if (self->last_errno == 0) nn_sock_stat_increment (self->sock, NN_STAT_CURRENT_EP_ERRORS, 1); self->last_errno = errnum; nn_sock_report_error (self->sock, self, errnum); } void nn_ep_clear_error (struct nn_ep *self) { if (self->last_errno == 0) /* Error is already clear, no need to report it */ return; nn_sock_stat_increment (self->sock, NN_STAT_CURRENT_EP_ERRORS, -1); self->last_errno = 0; nn_sock_report_error (self->sock, self, 0); } void nn_ep_stat_increment (struct nn_ep *self, int name, int increment) { nn_sock_stat_increment (self->sock, name, increment); } nanomsg-0.8-beta/src/core/epbase.c0000664000175000017500000000447312623652600017774 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "../transport.h" #include "ep.h" #include "sock.h" #include "../utils/attr.h" void nn_epbase_init (struct nn_epbase *self, const struct nn_epbase_vfptr *vfptr, void *hint) { self->vfptr = vfptr; self->ep = (struct nn_ep*) hint; } void nn_epbase_term (NN_UNUSED struct nn_epbase *self) { } void nn_epbase_stopped (struct nn_epbase *self) { nn_ep_stopped (self->ep); } struct nn_ctx *nn_epbase_getctx (struct nn_epbase *self) { return nn_ep_getctx (self->ep); } const char *nn_epbase_getaddr (struct nn_epbase *self) { return nn_ep_getaddr (self->ep); } void nn_epbase_getopt (struct nn_epbase *self, int level, int option, void *optval, size_t *optvallen) { nn_ep_getopt (self->ep, level, option, optval, optvallen); } int nn_epbase_ispeer (struct nn_epbase *self, int socktype) { return nn_ep_ispeer (self->ep, socktype); } void nn_epbase_set_error (struct nn_epbase *self, int errnum) { nn_ep_set_error (self->ep, errnum); } void nn_epbase_clear_error (struct nn_epbase *self) { nn_ep_clear_error (self->ep); } void nn_epbase_stat_increment(struct nn_epbase *self, int name, int increment) { nn_ep_stat_increment(self->ep, name, increment); } nanomsg-0.8-beta/src/core/global.h0000664000175000017500000000264512623652600020001 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_GLOBAL_INCLUDED #define NN_GLOBAL_INCLUDED /* Provides access to the list of available transports. */ struct nn_transport *nn_global_transport (int id); /* Returns the global worker thread pool. */ struct nn_pool *nn_global_getpool (); int nn_global_print_errors(); #endif nanomsg-0.8-beta/src/core/global.c0000664000175000017500000012141712623652600017773 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. All rights reserved. Copyright 2015 Garrett D'Amore 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 "../nn.h" #include "../transport.h" #include "../protocol.h" #include "global.h" #include "sock.h" #include "ep.h" #include "../aio/pool.h" #include "../aio/timer.h" #include "../utils/err.h" #include "../utils/alloc.h" #include "../utils/mutex.h" #include "../utils/list.h" #include "../utils/cont.h" #include "../utils/random.h" #include "../utils/glock.h" #include "../utils/chunk.h" #include "../utils/msg.h" #include "../utils/attr.h" #include "../transports/inproc/inproc.h" #include "../transports/ipc/ipc.h" #include "../transports/tcp/tcp.h" #include "../transports/ws/ws.h" #include "../transports/tcpmux/tcpmux.h" #include "../protocols/pair/pair.h" #include "../protocols/pair/xpair.h" #include "../protocols/pubsub/pub.h" #include "../protocols/pubsub/sub.h" #include "../protocols/pubsub/xpub.h" #include "../protocols/pubsub/xsub.h" #include "../protocols/reqrep/rep.h" #include "../protocols/reqrep/req.h" #include "../protocols/reqrep/xrep.h" #include "../protocols/reqrep/xreq.h" #include "../protocols/pipeline/push.h" #include "../protocols/pipeline/pull.h" #include "../protocols/pipeline/xpush.h" #include "../protocols/pipeline/xpull.h" #include "../protocols/survey/respondent.h" #include "../protocols/survey/surveyor.h" #include "../protocols/survey/xrespondent.h" #include "../protocols/survey/xsurveyor.h" #include "../protocols/bus/bus.h" #include "../protocols/bus/xbus.h" #include "../pubsub.h" #include "../pipeline.h" #include #include #include #include #if defined NN_HAVE_MINGW #include #elif defined NN_HAVE_WINDOWS #define gmtime_r(ptr_numtime, ptr_strtime) gmtime_s(ptr_strtime, ptr_numtime) #endif #define NN_HAVE_GMTIME_R #if defined NN_HAVE_WINDOWS #include "../utils/win.h" #else #include #endif /* Max number of concurrent SP sockets. */ #define NN_MAX_SOCKETS 512 /* To save some space, list of unused socket slots uses uint16_t integers to refer to individual sockets. If there's a need to more that 0x10000 sockets, the type should be changed to uint32_t or int. */ CT_ASSERT (NN_MAX_SOCKETS <= 0x10000); #define NN_CTX_FLAG_ZOMBIE 1 #define NN_GLOBAL_SRC_STAT_TIMER 1 #define NN_GLOBAL_STATE_IDLE 1 #define NN_GLOBAL_STATE_ACTIVE 2 #define NN_GLOBAL_STATE_STOPPING_TIMER 3 struct nn_global { /* The global table of existing sockets. The descriptor representing the socket is the index to this table. This pointer is also used to find out whether context is initialised. If it is NULL, context is uninitialised. */ struct nn_sock **socks; /* Stack of unused file descriptors. */ uint16_t *unused; /* Number of actual open sockets in the socket table. */ size_t nsocks; /* Combination of the flags listed above. */ int flags; /* List of all available transports. Note that this list is not dynamic; i.e. it is created during global initialization and is never modified. */ struct nn_list transports; /* List of all available socket types. Again this list is not dynamic.*/ struct nn_list socktypes; /* Pool of worker threads. */ struct nn_pool pool; /* Timer and other machinery for submitting statistics */ struct nn_ctx ctx; struct nn_fsm fsm; int state; struct nn_timer stat_timer; int print_errors; int print_statistics; /* Special socket ids */ int statistics_socket; /* Application name for statistics */ char hostname[64]; char appname[64]; }; /* Singleton object containing the global state of the library. */ static struct nn_global self; /* Context creation- and termination-related private functions. */ static void nn_global_init (void); static void nn_global_term (void); /* Transport-related private functions. */ static void nn_global_add_transport (struct nn_transport *transport); static void nn_global_add_socktype (struct nn_socktype *socktype); /* Private function that unifies nn_bind and nn_connect functionality. It returns the ID of the newly created endpoint. */ static int nn_global_create_ep (struct nn_sock *, const char *addr, int bind); /* Private socket creator which doesn't initialize global state and does no locking by itself */ static int nn_global_create_socket (int domain, int protocol); /* FSM callbacks */ static void nn_global_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_global_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); /* Socket holds. */ static int nn_global_hold_socket(struct nn_sock **sockp, int s); static int nn_global_hold_socket_locked(struct nn_sock **sockp, int s); static void nn_global_rele_socket(struct nn_sock *); int nn_errno (void) { return nn_err_errno (); } const char *nn_strerror (int errnum) { return nn_err_strerror (errnum); } static void nn_global_init (void) { int i; char *envvar; int rc; char *addr; #if defined NN_HAVE_WINDOWS WSADATA data; #endif /* Check whether the library was already initialised. If so, do nothing. */ if (self.socks) return; /* On Windows, initialise the socket library. */ #if defined NN_HAVE_WINDOWS rc = WSAStartup (MAKEWORD (2, 2), &data); nn_assert (rc == 0); nn_assert (LOBYTE (data.wVersion) == 2 && HIBYTE (data.wVersion) == 2); #endif /* Initialise the memory allocation subsystem. */ nn_alloc_init (); /* Seed the pseudo-random number generator. */ nn_random_seed (); /* Allocate the global table of SP sockets. */ self.socks = nn_alloc ((sizeof (struct nn_sock*) * NN_MAX_SOCKETS) + (sizeof (uint16_t) * NN_MAX_SOCKETS), "socket table"); alloc_assert (self.socks); for (i = 0; i != NN_MAX_SOCKETS; ++i) self.socks [i] = NULL; self.nsocks = 0; self.flags = 0; /* Print connection and accepting errors to the stderr */ envvar = getenv("NN_PRINT_ERRORS"); /* any non-empty string is true */ self.print_errors = envvar && *envvar; /* Print socket statistics to stderr */ envvar = getenv("NN_PRINT_STATISTICS"); self.print_statistics = envvar && *envvar; /* Allocate the stack of unused file descriptors. */ self.unused = (uint16_t*) (self.socks + NN_MAX_SOCKETS); alloc_assert (self.unused); for (i = 0; i != NN_MAX_SOCKETS; ++i) self.unused [i] = NN_MAX_SOCKETS - i - 1; /* Initialise other parts of the global state. */ nn_list_init (&self.transports); nn_list_init (&self.socktypes); /* Plug in individual transports. */ nn_global_add_transport (nn_inproc); nn_global_add_transport (nn_ipc); nn_global_add_transport (nn_tcp); nn_global_add_transport (nn_ws); nn_global_add_transport (nn_tcpmux); /* Plug in individual socktypes. */ nn_global_add_socktype (nn_pair_socktype); nn_global_add_socktype (nn_xpair_socktype); nn_global_add_socktype (nn_pub_socktype); nn_global_add_socktype (nn_sub_socktype); nn_global_add_socktype (nn_xpub_socktype); nn_global_add_socktype (nn_xsub_socktype); nn_global_add_socktype (nn_rep_socktype); nn_global_add_socktype (nn_req_socktype); nn_global_add_socktype (nn_xrep_socktype); nn_global_add_socktype (nn_xreq_socktype); nn_global_add_socktype (nn_push_socktype); nn_global_add_socktype (nn_xpush_socktype); nn_global_add_socktype (nn_pull_socktype); nn_global_add_socktype (nn_xpull_socktype); nn_global_add_socktype (nn_respondent_socktype); nn_global_add_socktype (nn_surveyor_socktype); nn_global_add_socktype (nn_xrespondent_socktype); nn_global_add_socktype (nn_xsurveyor_socktype); nn_global_add_socktype (nn_bus_socktype); nn_global_add_socktype (nn_xbus_socktype); /* Start the worker threads. */ nn_pool_init (&self.pool); /* Start FSM */ nn_fsm_init_root (&self.fsm, nn_global_handler, nn_global_shutdown, &self.ctx); self.state = NN_GLOBAL_STATE_IDLE; nn_ctx_init (&self.ctx, nn_global_getpool (), NULL); nn_timer_init (&self.stat_timer, NN_GLOBAL_SRC_STAT_TIMER, &self.fsm); /* Initializing special sockets. */ addr = getenv ("NN_STATISTICS_SOCKET"); if (addr) { self.statistics_socket = nn_global_create_socket (AF_SP, NN_PUB); errno_assert (self.statistics_socket >= 0); rc = nn_global_create_ep (self.socks[self.statistics_socket], addr, 0); errno_assert (rc >= 0); } else { self.statistics_socket = -1; } addr = getenv ("NN_APPLICATION_NAME"); if (addr) { strncpy (self.appname, addr, 63); self.appname[63] = '\0'; } else { /* No cross-platform way to find out application binary. Also, MSVC suggests using _getpid() instead of getpid(), however, it's not clear whether the former is supported by older versions of Windows/MSVC. */ #if defined _MSC_VER #pragma warning (push) #pragma warning (disable:4996) #endif sprintf (self.appname, "nanomsg.%d", getpid()); #if defined _MSC_VER #pragma warning (pop) #endif } addr = getenv ("NN_HOSTNAME"); if (addr) { strncpy (self.hostname, addr, 63); self.hostname[63] = '\0'; } else { rc = gethostname (self.hostname, 63); errno_assert (rc == 0); self.hostname[63] = '\0'; } nn_fsm_start(&self.fsm); } static void nn_global_term (void) { #if defined NN_HAVE_WINDOWS int rc; #endif struct nn_list_item *it; struct nn_transport *tp; /* If there are no sockets remaining, uninitialise the global context. */ nn_assert (self.socks); if (self.nsocks > 0) return; /* Stop the FSM */ nn_ctx_enter (&self.ctx); nn_fsm_stop (&self.fsm); nn_ctx_leave (&self.ctx); /* Shut down the worker threads. */ nn_pool_term (&self.pool); /* Terminate ctx mutex */ nn_ctx_term (&self.ctx); /* Ask all the transport to deallocate their global resources. */ while (!nn_list_empty (&self.transports)) { it = nn_list_begin (&self.transports); tp = nn_cont (it, struct nn_transport, item); if (tp->term) tp->term (); nn_list_erase (&self.transports, it); } /* For now there's nothing to deallocate about socket types, however, let's remove them from the list anyway. */ while (!nn_list_empty (&self.socktypes)) nn_list_erase (&self.socktypes, nn_list_begin (&self.socktypes)); /* Final deallocation of the nn_global object itself. */ nn_list_term (&self.socktypes); nn_list_term (&self.transports); nn_free (self.socks); /* This marks the global state as uninitialised. */ self.socks = NULL; /* Shut down the memory allocation subsystem. */ nn_alloc_term (); /* On Windows, uninitialise the socket library. */ #if defined NN_HAVE_WINDOWS rc = WSACleanup (); nn_assert (rc == 0); #endif } void nn_term (void) { int i; nn_glock_lock (); /* Switch the global state into the zombie state. */ self.flags |= NN_CTX_FLAG_ZOMBIE; /* Mark all open sockets as terminating. */ if (self.socks && self.nsocks) { for (i = 0; i != NN_MAX_SOCKETS; ++i) if (self.socks [i]) nn_sock_zombify (self.socks [i]); } nn_glock_unlock (); } void *nn_allocmsg (size_t size, int type) { int rc; void *result; rc = nn_chunk_alloc (size, type, &result); if (rc == 0) return result; errno = -rc; return NULL; } void *nn_reallocmsg (void *msg, size_t size) { int rc; rc = nn_chunk_realloc (size, &msg); if (rc == 0) return msg; errno = -rc; return NULL; } int nn_freemsg (void *msg) { nn_chunk_free (msg); return 0; } struct nn_cmsghdr *nn_cmsg_nxthdr_ (const struct nn_msghdr *mhdr, const struct nn_cmsghdr *cmsg) { char *data; size_t sz; struct nn_cmsghdr *next; size_t headsz; /* Early return if no message is provided. */ if (nn_slow (mhdr == NULL)) return NULL; /* Get the actual data. */ if (mhdr->msg_controllen == NN_MSG) { data = *((void**) mhdr->msg_control); sz = nn_chunk_size (data); } else { data = (char*) mhdr->msg_control; sz = mhdr->msg_controllen; } /* Ancillary data allocation was not even large enough for one element. */ if (nn_slow (sz < NN_CMSG_SPACE (0))) return NULL; /* If cmsg is set to NULL we are going to return first property. Otherwise move to the next property. */ if (!cmsg) next = (struct nn_cmsghdr*) data; else next = (struct nn_cmsghdr*) (((char*) cmsg) + NN_CMSG_ALIGN_ (cmsg->cmsg_len)); /* If there's no space for next property, treat it as the end of the property list. */ headsz = ((char*) next) - data; if (headsz + NN_CMSG_SPACE (0) > sz || headsz + NN_CMSG_ALIGN_ (next->cmsg_len) > sz) return NULL; /* Success. */ return next; } int nn_global_create_socket (int domain, int protocol) { int rc; int s; struct nn_list_item *it; struct nn_socktype *socktype; struct nn_sock *sock; /* The function is called with nn_glock held */ /* Only AF_SP and AF_SP_RAW domains are supported. */ if (nn_slow (domain != AF_SP && domain != AF_SP_RAW)) { return -EAFNOSUPPORT; } /* If socket limit was reached, report error. */ if (nn_slow (self.nsocks >= NN_MAX_SOCKETS)) { return -EMFILE; } /* Find an empty socket slot. */ s = self.unused [NN_MAX_SOCKETS - self.nsocks - 1]; /* Find the appropriate socket type. */ for (it = nn_list_begin (&self.socktypes); it != nn_list_end (&self.socktypes); it = nn_list_next (&self.socktypes, it)) { socktype = nn_cont (it, struct nn_socktype, item); if (socktype->domain == domain && socktype->protocol == protocol) { /* Instantiate the socket. */ sock = nn_alloc (sizeof (struct nn_sock), "sock"); alloc_assert (sock); rc = nn_sock_init (sock, socktype, s); if (rc < 0) return rc; /* Adjust the global socket table. */ self.socks [s] = sock; ++self.nsocks; return s; } } /* Specified socket type wasn't found. */ return -EINVAL; } int nn_socket (int domain, int protocol) { int rc; nn_glock_lock (); /* If nn_term() was already called, return ETERM. */ if (nn_slow (self.flags & NN_CTX_FLAG_ZOMBIE)) { nn_glock_unlock (); errno = ETERM; return -1; } /* Make sure that global state is initialised. */ nn_global_init (); rc = nn_global_create_socket (domain, protocol); if (rc < 0) { nn_global_term (); nn_glock_unlock (); errno = -rc; return -1; } nn_glock_unlock(); return rc; } int nn_close (int s) { int rc; struct nn_sock *sock; nn_glock_lock (); rc = nn_global_hold_socket_locked (&sock, s); if (nn_slow (rc < 0)) { nn_glock_unlock (); errno = -rc; return -1; } /* Start the shutdown process on the socket. This will cause all other socket users, as well as endpoints, to begin cleaning up. This is done with the glock held to ensure that two instances of nn_close can't access the same socket. */ nn_sock_stop (sock); nn_glock_unlock (); /* We have to drop both the hold we just acquired, as well as the original hold, in order for nn_sock_term to complete. */ nn_sock_rele (sock); nn_sock_rele (sock); /* Now clean up. The termination routine below will block until all other consumers of the socket have dropped their holds, and all endpoints have cleanly exited. */ rc = nn_sock_term (sock); if (nn_slow (rc == -EINTR)) { nn_global_rele_socket (sock); errno = EINTR; return -1; } /* Remove the socket from the socket table, add it to unused socket table. */ nn_glock_lock (); self.socks [s] = NULL; self.unused [NN_MAX_SOCKETS - self.nsocks] = s; --self.nsocks; nn_free (sock); /* Destroy the global context if there's no socket remaining. */ nn_global_term (); nn_glock_unlock (); return 0; } int nn_setsockopt (int s, int level, int option, const void *optval, size_t optvallen) { int rc; struct nn_sock *sock; rc = nn_global_hold_socket (&sock, s); if (nn_slow (rc < 0)) { errno = -rc; return -1; } if (nn_slow (!optval && optvallen)) { rc = -EFAULT; goto fail; } rc = nn_sock_setopt (sock, level, option, optval, optvallen); if (nn_slow (rc < 0)) goto fail; errnum_assert (rc == 0, -rc); nn_global_rele_socket (sock); return 0; fail: nn_global_rele_socket (sock); errno = -rc; return -1; } int nn_getsockopt (int s, int level, int option, void *optval, size_t *optvallen) { int rc; struct nn_sock *sock; rc = nn_global_hold_socket (&sock, s); if (nn_slow (rc < 0)) { errno = -rc; return -1; } if (nn_slow (!optval && optvallen)) { rc = -EFAULT; goto fail; } rc = nn_sock_getopt (sock, level, option, optval, optvallen); if (nn_slow (rc < 0)) goto fail; errnum_assert (rc == 0, -rc); nn_global_rele_socket (sock); return 0; fail: nn_global_rele_socket (sock); errno = -rc; return -1; } int nn_bind (int s, const char *addr) { int rc; struct nn_sock *sock; rc = nn_global_hold_socket (&sock, s); if (rc < 0) { errno = -rc; return -1; } rc = nn_global_create_ep (sock, addr, 1); if (nn_slow (rc < 0)) { nn_global_rele_socket (sock); errno = -rc; return -1; } nn_global_rele_socket (sock); return rc; } int nn_connect (int s, const char *addr) { int rc; struct nn_sock *sock; rc = nn_global_hold_socket (&sock, s); if (nn_slow (rc < 0)) { errno = -rc; return -1; } rc = nn_global_create_ep (sock, addr, 0); if (rc < 0) { nn_global_rele_socket (sock); errno = -rc; return -1; } nn_global_rele_socket (sock); return rc; } int nn_shutdown (int s, int how) { int rc; struct nn_sock *sock; rc = nn_global_hold_socket (&sock, s); if (nn_slow (rc < 0)) { errno = -rc; return -1; } rc = nn_sock_rm_ep (sock, how); if (nn_slow (rc < 0)) { nn_global_rele_socket (sock); errno = -rc; return -1; } nn_assert (rc == 0); nn_global_rele_socket (sock); return 0; } int nn_send (int s, const void *buf, size_t len, int flags) { struct nn_iovec iov; struct nn_msghdr hdr; iov.iov_base = (void*) buf; iov.iov_len = len; hdr.msg_iov = &iov; hdr.msg_iovlen = 1; hdr.msg_control = NULL; hdr.msg_controllen = 0; return nn_sendmsg (s, &hdr, flags); } int nn_recv (int s, void *buf, size_t len, int flags) { struct nn_iovec iov; struct nn_msghdr hdr; iov.iov_base = buf; iov.iov_len = len; hdr.msg_iov = &iov; hdr.msg_iovlen = 1; hdr.msg_control = NULL; hdr.msg_controllen = 0; return nn_recvmsg (s, &hdr, flags); } int nn_sendmsg (int s, const struct nn_msghdr *msghdr, int flags) { int rc; size_t sz; size_t spsz; int i; struct nn_iovec *iov; struct nn_msg msg; void *chunk; int nnmsg; struct nn_cmsghdr *cmsg; struct nn_sock *sock; rc = nn_global_hold_socket (&sock, s); if (nn_slow (rc < 0)) { errno = -rc; return -1; } if (nn_slow (!msghdr)) { rc = -EINVAL; goto fail; } if (nn_slow (msghdr->msg_iovlen < 0)) { rc = -EMSGSIZE; goto fail; } if (msghdr->msg_iovlen == 1 && msghdr->msg_iov [0].iov_len == NN_MSG) { chunk = *(void**) msghdr->msg_iov [0].iov_base; if (nn_slow (chunk == NULL)) { rc = -EFAULT; goto fail; } sz = nn_chunk_size (chunk); nn_msg_init_chunk (&msg, chunk); nnmsg = 1; } else { /* Compute the total size of the message. */ sz = 0; for (i = 0; i != msghdr->msg_iovlen; ++i) { iov = &msghdr->msg_iov [i]; if (nn_slow (iov->iov_len == NN_MSG)) { rc = -EINVAL; goto fail; } if (nn_slow (!iov->iov_base && iov->iov_len)) { rc = -EFAULT; goto fail; } if (nn_slow (sz + iov->iov_len < sz)) { rc = -EINVAL; goto fail; } sz += iov->iov_len; } /* Create a message object from the supplied scatter array. */ nn_msg_init (&msg, sz); sz = 0; for (i = 0; i != msghdr->msg_iovlen; ++i) { iov = &msghdr->msg_iov [i]; memcpy (((uint8_t*) nn_chunkref_data (&msg.body)) + sz, iov->iov_base, iov->iov_len); sz += iov->iov_len; } nnmsg = 0; } /* Add ancillary data to the message. */ if (msghdr->msg_control) { /* Copy all headers. */ /* TODO: SP_HDR should not be copied here! */ if (msghdr->msg_controllen == NN_MSG) { chunk = *((void**) msghdr->msg_control); nn_chunkref_term (&msg.hdrs); nn_chunkref_init_chunk (&msg.hdrs, chunk); } else { nn_chunkref_term (&msg.hdrs); nn_chunkref_init (&msg.hdrs, msghdr->msg_controllen); memcpy (nn_chunkref_data (&msg.hdrs), msghdr->msg_control, msghdr->msg_controllen); } /* Search for SP_HDR property. */ cmsg = NN_CMSG_FIRSTHDR (msghdr); while (cmsg) { if (cmsg->cmsg_level == PROTO_SP && cmsg->cmsg_type == SP_HDR) { unsigned char *ptr = NN_CMSG_DATA (cmsg); size_t clen = cmsg->cmsg_len - NN_CMSG_SPACE (0); if (clen > sizeof (size_t)) { spsz = *(size_t *)(void *)ptr; if (spsz <= (clen - sizeof (size_t))) { /* Copy body of SP_HDR property into 'sphdr'. */ nn_chunkref_term (&msg.sphdr); nn_chunkref_init (&msg.sphdr, spsz); memcpy (nn_chunkref_data (&msg.sphdr), ptr + sizeof (size_t), spsz); } } break; } cmsg = NN_CMSG_NXTHDR (msghdr, cmsg); } } /* Send it further down the stack. */ rc = nn_sock_send (sock, &msg, flags); if (nn_slow (rc < 0)) { /* If we are dealing with user-supplied buffer, detach it from the message object. */ if (nnmsg) nn_chunkref_init (&msg.body, 0); nn_msg_term (&msg); goto fail; } /* Adjust the statistics. */ nn_sock_stat_increment (sock, NN_STAT_MESSAGES_SENT, 1); nn_sock_stat_increment (sock, NN_STAT_BYTES_SENT, sz); nn_global_rele_socket (sock); return (int) sz; fail: nn_global_rele_socket (sock); errno = -rc; return -1; } int nn_recvmsg (int s, struct nn_msghdr *msghdr, int flags) { int rc; struct nn_msg msg; uint8_t *data; size_t sz; int i; struct nn_iovec *iov; void *chunk; size_t hdrssz; void *ctrl; size_t ctrlsz; size_t spsz; size_t sptotalsz; struct nn_cmsghdr *chdr; struct nn_sock *sock; rc = nn_global_hold_socket (&sock, s); if (nn_slow (rc < 0)) { errno = -rc; return -1; } if (nn_slow (!msghdr)) { rc = -EINVAL; goto fail; } if (nn_slow (msghdr->msg_iovlen < 0)) { rc = -EMSGSIZE; goto fail; } /* Get a message. */ rc = nn_sock_recv (sock, &msg, flags); if (nn_slow (rc < 0)) { goto fail; } if (msghdr->msg_iovlen == 1 && msghdr->msg_iov [0].iov_len == NN_MSG) { chunk = nn_chunkref_getchunk (&msg.body); *(void**) (msghdr->msg_iov [0].iov_base) = chunk; sz = nn_chunk_size (chunk); } else { /* Copy the message content into the supplied gather array. */ data = nn_chunkref_data (&msg.body); sz = nn_chunkref_size (&msg.body); for (i = 0; i != msghdr->msg_iovlen; ++i) { iov = &msghdr->msg_iov [i]; if (nn_slow (iov->iov_len == NN_MSG)) { nn_msg_term (&msg); rc = -EINVAL; goto fail; } if (iov->iov_len > sz) { memcpy (iov->iov_base, data, sz); break; } memcpy (iov->iov_base, data, iov->iov_len); data += iov->iov_len; sz -= iov->iov_len; } sz = nn_chunkref_size (&msg.body); } /* Retrieve the ancillary data from the message. */ if (msghdr->msg_control) { spsz = nn_chunkref_size (&msg.sphdr); sptotalsz = NN_CMSG_SPACE (spsz+sizeof (size_t)); ctrlsz = sptotalsz + nn_chunkref_size (&msg.hdrs); if (msghdr->msg_controllen == NN_MSG) { /* Allocate the buffer. */ rc = nn_chunk_alloc (ctrlsz, 0, &ctrl); errnum_assert (rc == 0, -rc); /* Set output parameters. */ *((void**) msghdr->msg_control) = ctrl; } else { /* Just use the buffer supplied by the user. */ ctrl = msghdr->msg_control; ctrlsz = msghdr->msg_controllen; } /* If SP header alone won't fit into the buffer, return no ancillary properties. */ if (ctrlsz >= sptotalsz) { char *ptr; /* Fill in SP_HDR ancillary property. */ chdr = (struct nn_cmsghdr*) ctrl; chdr->cmsg_len = sptotalsz; chdr->cmsg_level = PROTO_SP; chdr->cmsg_type = SP_HDR; ptr = (void *)chdr; ptr += sizeof (*chdr); *(size_t *)(void *)ptr = spsz; ptr += sizeof (size_t); memcpy (ptr, nn_chunkref_data (&msg.sphdr), spsz); /* Fill in as many remaining properties as possible. Truncate the trailing properties if necessary. */ hdrssz = nn_chunkref_size (&msg.hdrs); if (hdrssz > ctrlsz - sptotalsz) hdrssz = ctrlsz - sptotalsz; memcpy (((char*) ctrl) + sptotalsz, nn_chunkref_data (&msg.hdrs), hdrssz); } } nn_msg_term (&msg); /* Adjust the statistics. */ nn_sock_stat_increment (sock, NN_STAT_MESSAGES_RECEIVED, 1); nn_sock_stat_increment (sock, NN_STAT_BYTES_RECEIVED, sz); nn_global_rele_socket (sock); return (int) sz; fail: nn_global_rele_socket (sock); errno = -rc; return -1; } static void nn_global_add_transport (struct nn_transport *transport) { if (transport->init) transport->init (); nn_list_insert (&self.transports, &transport->item, nn_list_end (&self.transports)); } static void nn_global_add_socktype (struct nn_socktype *socktype) { nn_list_insert (&self.socktypes, &socktype->item, nn_list_end (&self.socktypes)); } static void nn_global_submit_counter (int i, struct nn_sock *s, char *name, uint64_t value) { /* Length of buffer is: len(hostname) + len(appname) + len(socket_name) + len(timebuf) + len(str(value)) + len(static characters) 63 + 63 + 63 + 20 + 20 + 60 = 289 */ char buf[512]; char timebuf[20]; time_t numtime; struct tm strtime; int len; if(self.print_statistics) { fprintf(stderr, "nanomsg: socket.%s: %s: %llu\n", s->socket_name, name, (long long unsigned int)value); } if (self.statistics_socket >= 0) { /* TODO(tailhook) add HAVE_GMTIME_R ifdef */ time(&numtime); #ifdef NN_HAVE_GMTIME_R gmtime_r (&numtime, &strtime); #else #error #endif strftime (timebuf, 20, "%Y-%m-%dT%H:%M:%S", &strtime); if(*s->socket_name) { len = sprintf (buf, "ESTP:%s:%s:socket.%s:%s: %sZ 10 %llu:c", self.hostname, self.appname, s->socket_name, name, timebuf, (long long unsigned int)value); } else { len = sprintf (buf, "ESTP:%s:%s:socket.%d:%s: %sZ 10 %llu:c", self.hostname, self.appname, i, name, timebuf, (long long unsigned int)value); } nn_assert (len < (int)sizeof(buf)); (void) nn_send (self.statistics_socket, buf, len, NN_DONTWAIT); } } static void nn_global_submit_level (int i, struct nn_sock *s, char *name, int value) { /* Length of buffer is: len(hostname) + len(appname) + len(socket_name) + len(timebuf) + len(str(value)) + len(static characters) 63 + 63 + 63 + 20 + 20 + 60 = 289 */ char buf[512]; char timebuf[20]; time_t numtime; struct tm strtime; int len; if(self.print_statistics) { fprintf(stderr, "nanomsg: socket.%s: %s: %d\n", s->socket_name, name, value); } if (self.statistics_socket >= 0) { /* TODO(tailhook) add HAVE_GMTIME_R ifdef */ time(&numtime); #ifdef NN_HAVE_GMTIME_R gmtime_r (&numtime, &strtime); #else #error #endif strftime (timebuf, 20, "%Y-%m-%dT%H:%M:%S", &strtime); if(*s->socket_name) { len = sprintf (buf, "ESTP:%s:%s:socket.%s:%s: %sZ 10 %d", self.hostname, self.appname, s->socket_name, name, timebuf, value); } else { len = sprintf (buf, "ESTP:%s:%s:socket.%d:%s: %sZ 10 %d", self.hostname, self.appname, i, name, timebuf, value); } nn_assert (len < (int)sizeof(buf)); (void) nn_send (self.statistics_socket, buf, len, NN_DONTWAIT); } } static void nn_global_submit_errors (int i, struct nn_sock *s, char *name, int value) { /* TODO(tailhook) dynamically allocate buffer */ char buf[4096]; char *curbuf; int buf_left; char timebuf[20]; time_t numtime; struct tm strtime; int len; struct nn_list_item *it; struct nn_ep *ep; if (self.statistics_socket >= 0) { /* TODO(tailhook) add HAVE_GMTIME_R ifdef */ time(&numtime); #ifdef NN_HAVE_GMTIME_R gmtime_r (&numtime, &strtime); #else #error #endif strftime (timebuf, 20, "%Y-%m-%dT%H:%M:%S", &strtime); if(*s->socket_name) { len = sprintf (buf, "ESTP:%s:%s:socket.%s:%s: %sZ 10 %d\n", self.hostname, self.appname, s->socket_name, name, timebuf, value); } else { len = sprintf (buf, "ESTP:%s:%s:socket.%d:%s: %sZ 10 %d\n", self.hostname, self.appname, i, name, timebuf, value); } buf_left = sizeof(buf) - len; curbuf = buf + len; for (it = nn_list_begin (&s->eps); it != nn_list_end (&s->eps); it = nn_list_next (&s->eps, it)) { ep = nn_cont (it, struct nn_ep, item); if (ep->last_errno) { #ifdef NN_HAVE_WINDOWS len = _snprintf_s (curbuf, buf_left, _TRUNCATE, " nanomsg: Endpoint %d [%s] error: %s\n", ep->eid, nn_ep_getaddr (ep), nn_strerror (ep->last_errno)); #else len = snprintf (curbuf, buf_left, " nanomsg: Endpoint %d [%s] error: %s\n", ep->eid, nn_ep_getaddr (ep), nn_strerror (ep->last_errno)); #endif if (buf_left < len) break; curbuf += len; buf_left -= len; } } (void) nn_send (self.statistics_socket, buf, sizeof(buf) - buf_left, NN_DONTWAIT); } } static void nn_global_submit_statistics () { int i; struct nn_sock *s; /* TODO(tailhook) optimized it to use nsocks and unused */ for(i = 0; i < NN_MAX_SOCKETS; ++i) { nn_glock_lock (); s = self.socks [i]; if (!s) { nn_glock_unlock (); continue; } if (i == self.statistics_socket) { nn_glock_unlock (); continue; } nn_ctx_enter (&s->ctx); nn_glock_unlock (); nn_global_submit_counter (i, s, "established_connections", s->statistics.established_connections); nn_global_submit_counter (i, s, "accepted_connections", s->statistics.accepted_connections); nn_global_submit_counter (i, s, "dropped_connections", s->statistics.dropped_connections); nn_global_submit_counter (i, s, "broken_connections", s->statistics.broken_connections); nn_global_submit_counter (i, s, "connect_errors", s->statistics.connect_errors); nn_global_submit_counter (i, s, "bind_errors", s->statistics.bind_errors); nn_global_submit_counter (i, s, "accept_errors", s->statistics.accept_errors); nn_global_submit_counter (i, s, "messages_sent", s->statistics.messages_sent); nn_global_submit_counter (i, s, "messages_received", s->statistics.messages_received); nn_global_submit_counter (i, s, "bytes_sent", s->statistics.bytes_sent); nn_global_submit_counter (i, s, "bytes_received", s->statistics.bytes_received); nn_global_submit_level (i, s, "current_connections", s->statistics.current_connections); nn_global_submit_level (i, s, "inprogress_connections", s->statistics.inprogress_connections); nn_global_submit_level (i, s, "current_snd_priority", s->statistics.current_snd_priority); nn_global_submit_errors (i, s, "current_ep_errors", s->statistics.current_ep_errors); nn_ctx_leave (&s->ctx); } } static int nn_global_create_ep (struct nn_sock *sock, const char *addr, int bind) { int rc; const char *proto; const char *delim; size_t protosz; struct nn_transport *tp; struct nn_list_item *it; /* Check whether address is valid. */ if (!addr) return -EINVAL; if (strlen (addr) >= NN_SOCKADDR_MAX) return -ENAMETOOLONG; /* Separate the protocol and the actual address. */ proto = addr; delim = strchr (addr, ':'); if (!delim) return -EINVAL; if (delim [1] != '/' || delim [2] != '/') return -EINVAL; protosz = delim - addr; addr += protosz + 3; /* Find the specified protocol. */ tp = NULL; for (it = nn_list_begin (&self.transports); it != nn_list_end (&self.transports); it = nn_list_next (&self.transports, it)) { tp = nn_cont (it, struct nn_transport, item); if (strlen (tp->name) == protosz && memcmp (tp->name, proto, protosz) == 0) break; tp = NULL; } /* The protocol specified doesn't match any known protocol. */ if (!tp) { return -EPROTONOSUPPORT; } /* Ask the socket to create the endpoint. */ rc = nn_sock_add_ep (sock, tp, bind, addr); return rc; } struct nn_transport *nn_global_transport (int id) { struct nn_transport *tp; struct nn_list_item *it; /* Find the specified protocol. */ tp = NULL; for (it = nn_list_begin (&self.transports); it != nn_list_end (&self.transports); it = nn_list_next (&self.transports, it)) { tp = nn_cont (it, struct nn_transport, item); if (tp->id == id) break; tp = NULL; } return tp; } struct nn_pool *nn_global_getpool () { return &self.pool; } static void nn_global_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_global *global; global = nn_cont (self, struct nn_global, fsm); switch (global->state) { /******************************************************************************/ /* IDLE state. */ /* The state machine wasn't yet started. */ /******************************************************************************/ case NN_GLOBAL_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: global->state = NN_GLOBAL_STATE_ACTIVE; if (global->print_statistics || global->statistics_socket >= 0) { /* Start statistics collection timer. */ nn_timer_start (&global->stat_timer, 10000); } return; default: nn_fsm_bad_action (global->state, src, type); } default: nn_fsm_bad_source (global->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /* Normal lifetime for global object. */ /******************************************************************************/ case NN_GLOBAL_STATE_ACTIVE: switch (src) { case NN_GLOBAL_SRC_STAT_TIMER: switch (type) { case NN_TIMER_TIMEOUT: nn_global_submit_statistics (); /* No need to change state */ nn_timer_stop (&global->stat_timer); return; case NN_TIMER_STOPPED: nn_timer_start (&global->stat_timer, 10000); return; default: nn_fsm_bad_action (global->state, src, type); } default: nn_fsm_bad_source (global->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (global->state, src, type); } } static void nn_global_shutdown (struct nn_fsm *self, NN_UNUSED int src, NN_UNUSED int type, NN_UNUSED void *srcptr) { struct nn_global *global; global = nn_cont (self, struct nn_global, fsm); nn_assert (global->state == NN_GLOBAL_STATE_ACTIVE || global->state == NN_GLOBAL_STATE_IDLE); if (global->state == NN_GLOBAL_STATE_ACTIVE) { if (!nn_timer_isidle (&global->stat_timer)) { nn_timer_stop (&global->stat_timer); return; } } } int nn_global_print_errors () { return self.print_errors; } /* Get the socket structure for a socket id. This must be called under the global lock (nn_glock_lock.) The socket itself will not be freed while the hold is active. */ int nn_global_hold_socket_locked(struct nn_sock **sockp, int s) { struct nn_sock *sock; if (nn_slow (self.socks == NULL)) { *sockp = NULL; return -ETERM; } if (nn_slow ((self.flags & NN_CTX_FLAG_ZOMBIE) != 0)) { *sockp = NULL; return -ETERM; } if (nn_slow (s < 0 || s >= NN_MAX_SOCKETS)) return -EBADF; sock = self.socks[s]; if (nn_slow (sock == NULL)) return -EBADF; if (nn_slow (nn_sock_hold (sock) != 0)) { return -EBADF; } *sockp = sock; return 0; } int nn_global_hold_socket(struct nn_sock **sockp, int s) { int rc; nn_glock_lock(); rc = nn_global_hold_socket_locked(sockp, s); nn_glock_unlock(); return rc; } void nn_global_rele_socket(struct nn_sock *sock) { nn_glock_lock(); nn_sock_rele(sock); nn_glock_unlock(); } nanomsg-0.8-beta/src/core/pipe.c0000664000175000017500000001557312623652600017475 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "../transport.h" #include "../protocol.h" #include "sock.h" #include "ep.h" #include "../utils/err.h" #include "../utils/fast.h" /* Internal pipe states. */ #define NN_PIPEBASE_STATE_IDLE 1 #define NN_PIPEBASE_STATE_ACTIVE 2 #define NN_PIPEBASE_STATE_FAILED 3 #define NN_PIPEBASE_INSTATE_DEACTIVATED 0 #define NN_PIPEBASE_INSTATE_IDLE 1 #define NN_PIPEBASE_INSTATE_RECEIVING 2 #define NN_PIPEBASE_INSTATE_RECEIVED 3 #define NN_PIPEBASE_INSTATE_ASYNC 4 #define NN_PIPEBASE_OUTSTATE_DEACTIVATED 0 #define NN_PIPEBASE_OUTSTATE_IDLE 1 #define NN_PIPEBASE_OUTSTATE_SENDING 2 #define NN_PIPEBASE_OUTSTATE_SENT 3 #define NN_PIPEBASE_OUTSTATE_ASYNC 4 void nn_pipebase_init (struct nn_pipebase *self, const struct nn_pipebase_vfptr *vfptr, struct nn_epbase *epbase) { nn_assert (epbase->ep->sock); nn_fsm_init (&self->fsm, NULL, NULL, 0, self, &epbase->ep->sock->fsm); self->vfptr = vfptr; self->state = NN_PIPEBASE_STATE_IDLE; self->instate = NN_PIPEBASE_INSTATE_DEACTIVATED; self->outstate = NN_PIPEBASE_OUTSTATE_DEACTIVATED; self->sock = epbase->ep->sock; memcpy (&self->options, &epbase->ep->options, sizeof (struct nn_ep_options)); nn_fsm_event_init (&self->in); nn_fsm_event_init (&self->out); } void nn_pipebase_term (struct nn_pipebase *self) { nn_assert_state (self, NN_PIPEBASE_STATE_IDLE); nn_fsm_event_term (&self->out); nn_fsm_event_term (&self->in); nn_fsm_term (&self->fsm); } int nn_pipebase_start (struct nn_pipebase *self) { int rc; nn_assert_state (self, NN_PIPEBASE_STATE_IDLE); self->state = NN_PIPEBASE_STATE_ACTIVE; self->instate = NN_PIPEBASE_INSTATE_ASYNC; self->outstate = NN_PIPEBASE_OUTSTATE_IDLE; rc = nn_sock_add (self->sock, (struct nn_pipe*) self); if (nn_slow (rc < 0)) { self->state = NN_PIPEBASE_STATE_FAILED; return rc; } if (self->sock) nn_fsm_raise (&self->fsm, &self->out, NN_PIPE_OUT); return 0; } void nn_pipebase_stop (struct nn_pipebase *self) { if (self->state == NN_PIPEBASE_STATE_ACTIVE) nn_sock_rm (self->sock, (struct nn_pipe*) self); self->state = NN_PIPEBASE_STATE_IDLE; } void nn_pipebase_received (struct nn_pipebase *self) { if (nn_fast (self->instate == NN_PIPEBASE_INSTATE_RECEIVING)) { self->instate = NN_PIPEBASE_INSTATE_RECEIVED; return; } nn_assert (self->instate == NN_PIPEBASE_INSTATE_ASYNC); self->instate = NN_PIPEBASE_INSTATE_IDLE; if (self->sock) nn_fsm_raise (&self->fsm, &self->in, NN_PIPE_IN); } void nn_pipebase_sent (struct nn_pipebase *self) { if (nn_fast (self->outstate == NN_PIPEBASE_OUTSTATE_SENDING)) { self->outstate = NN_PIPEBASE_OUTSTATE_SENT; return; } nn_assert (self->outstate == NN_PIPEBASE_OUTSTATE_ASYNC); self->outstate = NN_PIPEBASE_OUTSTATE_IDLE; if (self->sock) nn_fsm_raise (&self->fsm, &self->out, NN_PIPE_OUT); } void nn_pipebase_getopt (struct nn_pipebase *self, int level, int option, void *optval, size_t *optvallen) { int rc; int intval; if (level == NN_SOL_SOCKET) { switch (option) { /* Endpoint options */ case NN_SNDPRIO: intval = self->options.sndprio; break; case NN_RCVPRIO: intval = self->options.rcvprio; break; case NN_IPV4ONLY: intval = self->options.ipv4only; break; /* Fallback to socket options */ default: rc = nn_sock_getopt_inner (self->sock, level, option, optval, optvallen); errnum_assert (rc == 0, -rc); return; } memcpy (optval, &intval, *optvallen < sizeof (int) ? *optvallen : sizeof (int)); *optvallen = sizeof (int); return; } rc = nn_sock_getopt_inner (self->sock, level, option, optval, optvallen); errnum_assert (rc == 0, -rc); } int nn_pipebase_ispeer (struct nn_pipebase *self, int socktype) { return nn_sock_ispeer (self->sock, socktype); } void nn_pipe_setdata (struct nn_pipe *self, void *data) { ((struct nn_pipebase*) self)->data = data; } void *nn_pipe_getdata (struct nn_pipe *self) { return ((struct nn_pipebase*) self)->data; } int nn_pipe_send (struct nn_pipe *self, struct nn_msg *msg) { int rc; struct nn_pipebase *pipebase; pipebase = (struct nn_pipebase*) self; nn_assert (pipebase->outstate == NN_PIPEBASE_OUTSTATE_IDLE); pipebase->outstate = NN_PIPEBASE_OUTSTATE_SENDING; rc = pipebase->vfptr->send (pipebase, msg); errnum_assert (rc >= 0, -rc); if (nn_fast (pipebase->outstate == NN_PIPEBASE_OUTSTATE_SENT)) { pipebase->outstate = NN_PIPEBASE_OUTSTATE_IDLE; return rc; } nn_assert (pipebase->outstate == NN_PIPEBASE_OUTSTATE_SENDING); pipebase->outstate = NN_PIPEBASE_OUTSTATE_ASYNC; return rc | NN_PIPEBASE_RELEASE; } int nn_pipe_recv (struct nn_pipe *self, struct nn_msg *msg) { int rc; struct nn_pipebase *pipebase; pipebase = (struct nn_pipebase*) self; nn_assert (pipebase->instate == NN_PIPEBASE_INSTATE_IDLE); pipebase->instate = NN_PIPEBASE_INSTATE_RECEIVING; rc = pipebase->vfptr->recv (pipebase, msg); errnum_assert (rc >= 0, -rc); if (nn_fast (pipebase->instate == NN_PIPEBASE_INSTATE_RECEIVED)) { pipebase->instate = NN_PIPEBASE_INSTATE_IDLE; return rc; } nn_assert (pipebase->instate == NN_PIPEBASE_INSTATE_RECEIVING); pipebase->instate = NN_PIPEBASE_INSTATE_ASYNC; return rc | NN_PIPEBASE_RELEASE; } void nn_pipe_getopt (struct nn_pipe *self, int level, int option, void *optval, size_t *optvallen) { struct nn_pipebase *pipebase; pipebase = (struct nn_pipebase*) self; nn_pipebase_getopt (pipebase, level, option, optval, optvallen); } nanomsg-0.8-beta/src/core/poll.c0000664000175000017500000001357412623652600017505 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "../nn.h" #if defined NN_HAVE_WINDOWS #include "../utils/win.h" #include "../utils/fast.h" #include "../utils/sleep.h" #include "../utils/err.h" int nn_poll (struct nn_pollfd *fds, int nfds, int timeout) { int rc; int i; fd_set fdset; SOCKET fd; int res; size_t sz; struct timeval tv; /* Fill in the fdset, as appropriate. */ FD_ZERO (&fdset); for (i = 0; i != nfds; ++i) { if (fds [i].events & NN_POLLIN) { sz = sizeof (fd); rc = nn_getsockopt (fds [i].fd, NN_SOL_SOCKET, NN_RCVFD, &fd, &sz); if (nn_slow (rc < 0)) { errno = -rc; return -1; } nn_assert (sz == sizeof (fd)); FD_SET (fd, &fdset); } if (fds [i].events & NN_POLLOUT) { sz = sizeof (fd); rc = nn_getsockopt (fds [i].fd, NN_SOL_SOCKET, NN_SNDFD, &fd, &sz); if (nn_slow (rc < 0)) { errno = -rc; return -1; } nn_assert (sz == sizeof (fd)); FD_SET (fd, &fdset); } } /* Do the polling itself. */ tv.tv_sec = timeout / 1000; tv.tv_usec = timeout % 1000 * 1000; if (nn_fast (nfds)) { rc = select (-1, &fdset, NULL, NULL, &tv); if (nn_slow (rc == 0)) return 0; if (nn_slow (rc == SOCKET_ERROR)) { errno = nn_err_wsa_to_posix (WSAGetLastError ()); return -1; } } else { // POSIX platforms will sleep until timeout is expired, // so let's do the same on Windows. if (timeout > 0) nn_sleep(timeout); return 0; } /* Move the results from fdset to the nanomsg pollset. */ res = 0; for (i = 0; i != nfds; ++i) { fds [i].revents = 0; if (fds [i].events & NN_POLLIN) { sz = sizeof (fd); rc = nn_getsockopt (fds [i].fd, NN_SOL_SOCKET, NN_RCVFD, &fd, &sz); if (nn_slow (rc < 0)) { errno = -rc; return -1; } nn_assert (sz == sizeof (fd)); if (FD_ISSET (fd, &fdset)) fds [i].revents |= NN_POLLIN; } if (fds [i].events & NN_POLLOUT) { sz = sizeof (fd); rc = nn_getsockopt (fds [i].fd, NN_SOL_SOCKET, NN_SNDFD, &fd, &sz); if (nn_slow (rc < 0)) { errno = -rc; return -1; } nn_assert (sz == sizeof (fd)); if (FD_ISSET (fd, &fdset)) fds [i].revents |= NN_POLLOUT; } if (fds [i].revents) ++res; } return res; } #else #include "../utils/alloc.h" #include "../utils/fast.h" #include "../utils/err.h" #include #include int nn_poll (struct nn_pollfd *fds, int nfds, int timeout) { int rc; int i; int pos; int fd; int res; size_t sz; struct pollfd *pfd; /* Construct a pollset to be used with OS-level 'poll' function. */ pfd = nn_alloc (sizeof (struct pollfd) * nfds * 2, "pollset"); alloc_assert (pfd); pos = 0; for (i = 0; i != nfds; ++i) { if (fds [i].events & NN_POLLIN) { sz = sizeof (fd); rc = nn_getsockopt (fds [i].fd, NN_SOL_SOCKET, NN_RCVFD, &fd, &sz); if (nn_slow (rc < 0)) { nn_free (pfd); errno = -rc; return -1; } nn_assert (sz == sizeof (fd)); pfd [pos].fd = fd; pfd [pos].events = POLLIN; ++pos; } if (fds [i].events & NN_POLLOUT) { sz = sizeof (fd); rc = nn_getsockopt (fds [i].fd, NN_SOL_SOCKET, NN_SNDFD, &fd, &sz); if (nn_slow (rc < 0)) { nn_free (pfd); errno = -rc; return -1; } nn_assert (sz == sizeof (fd)); pfd [pos].fd = fd; pfd [pos].events = POLLIN; ++pos; } } /* Do the polling itself. */ rc = poll (pfd, pos, timeout); if (nn_slow (rc <= 0)) { res = errno; nn_free (pfd); errno = res; return rc; } /* Move the results from OS-level poll to nn_poll's pollset. */ res = 0; pos = 0; for (i = 0; i != nfds; ++i) { fds [i].revents = 0; if (fds [i].events & NN_POLLIN) { if (pfd [pos].revents & POLLIN) fds [i].revents |= NN_POLLIN; ++pos; } if (fds [i].events & NN_POLLOUT) { if (pfd [pos].revents & POLLIN) fds [i].revents |= NN_POLLOUT; ++pos; } if (fds [i].revents) ++res; } nn_free (pfd); return res; } #endif nanomsg-0.8-beta/src/core/sock.h0000664000175000017500000001536612623652600017504 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_SOCK_INCLUDED #define NN_SOCK_INCLUDED #include "../protocol.h" #include "../transport.h" #include "../aio/ctx.h" #include "../aio/fsm.h" #include "../utils/efd.h" #include "../utils/sem.h" #include "../utils/clock.h" #include "../utils/list.h" struct nn_pipe; /* The maximum implemented transport ID. */ #define NN_MAX_TRANSPORT 4 /* The socket-internal statistics */ #define NN_STAT_MESSAGES_SENT 301 #define NN_STAT_MESSAGES_RECEIVED 302 #define NN_STAT_BYTES_SENT 303 #define NN_STAT_BYTES_RECEIVED 304 struct nn_sock { /* Socket state machine. */ struct nn_fsm fsm; int state; /* Pointer to the instance of the specific socket type. */ struct nn_sockbase *sockbase; /* Pointer to the socket type metadata. */ struct nn_socktype *socktype; int flags; struct nn_ctx ctx; struct nn_efd sndfd; struct nn_efd rcvfd; struct nn_sem termsem; struct nn_sem relesem; /* TODO: This clock can be accessed from different threads. If RDTSC is out-of-sync among different CPU cores, this can be a problem. */ struct nn_clock clock; /* List of all endpoints associated with the socket. */ struct nn_list eps; /* List of all endpoint being in the process of shutting down. */ struct nn_list sdeps; /* Next endpoint ID to assign to a new endpoint. */ int eid; /* Count of active holds against the socket. */ int holds; /* Socket-level socket options. */ int linger; int sndbuf; int rcvbuf; int rcvmaxsize; int sndtimeo; int rcvtimeo; int reconnect_ivl; int reconnect_ivl_max; /* Endpoint-specific options. */ struct nn_ep_options ep_template; /* Transport-specific socket options. */ struct nn_optset *optsets [NN_MAX_TRANSPORT]; struct { /***** The ever-incrementing counters *****/ /* Successfully established nn_connect() connections */ uint64_t established_connections; /* Successfully accepted connections */ uint64_t accepted_connections; /* Forcedly closed connections */ uint64_t dropped_connections; /* Connections closed by peer */ uint64_t broken_connections; /* Errors trying to establish active connection */ uint64_t connect_errors; /* Errors binding to specified port */ uint64_t bind_errors; /* Errors accepting connections at nn_bind()'ed endpoint */ uint64_t accept_errors; /* Messages sent */ uint64_t messages_sent; /* Messages received */ uint64_t messages_received; /* Bytes sent (sum length of data in messages sent) */ uint64_t bytes_sent; /* Bytes recevied (sum length of data in messages received) */ uint64_t bytes_received; /***** Level-style values *****/ /* Number of currently established connections */ int current_connections; /* Number of connections currently in progress */ int inprogress_connections; /* The currently set priority for sending data */ int current_snd_priority; /* Number of endpoints having last_errno set to non-zero value */ int current_ep_errors; } statistics; /* The socket name for statistics */ char socket_name[64]; }; /* Initialise the socket. */ int nn_sock_init (struct nn_sock *self, struct nn_socktype *socktype, int fd); /* Called by nn_close() to stop activity on the socket. It doesn't block. */ void nn_sock_stop (struct nn_sock *self); /* Called by nn_close() to deallocate the socket. It's a blocking function and can return -EINTR. */ int nn_sock_term (struct nn_sock *self); /* Called by sockbase when stopping is done. */ void nn_sock_stopped (struct nn_sock *self); /* Called by nn_term() to let the socket know about the process shutdown. */ void nn_sock_zombify (struct nn_sock *self); /* Returns the AIO context associated with the socket. */ struct nn_ctx *nn_sock_getctx (struct nn_sock *self); /* Returns 1 if the specified socket type is a valid peer for this socket, 0 otherwise. */ int nn_sock_ispeer (struct nn_sock *self, int socktype); /* Add new endpoint to the socket. */ int nn_sock_add_ep (struct nn_sock *self, struct nn_transport *transport, int bind, const char *addr); /* Remove the endpoint with the specified ID from the socket. */ int nn_sock_rm_ep (struct nn_sock *self, int eid); /* Send a message to the socket. */ int nn_sock_send (struct nn_sock *self, struct nn_msg *msg, int flags); /* Receive a message from the socket. */ int nn_sock_recv (struct nn_sock *self, struct nn_msg *msg, int flags); /* Set a socket option. */ int nn_sock_setopt (struct nn_sock *self, int level, int option, const void *optval, size_t optvallen); /* Retrieve a socket option. This function is to be called from the API. */ int nn_sock_getopt (struct nn_sock *self, int level, int option, void *optval, size_t *optvallen); /* Retrieve a socket option. This function is to be called from within the socket. */ int nn_sock_getopt_inner (struct nn_sock *self, int level, int option, void *optval, size_t *optvallen); /* Used by pipes. */ int nn_sock_add (struct nn_sock *self, struct nn_pipe *pipe); void nn_sock_rm (struct nn_sock *self, struct nn_pipe *pipe); /* Monitoring callbacks */ void nn_sock_report_error(struct nn_sock *self, struct nn_ep *ep, int errnum); void nn_sock_stat_increment(struct nn_sock *self, int name, int64_t increment); /* Holds and releases. */ int nn_sock_hold (struct nn_sock *self); void nn_sock_rele (struct nn_sock *self); #endif nanomsg-0.8-beta/src/core/sock.c0000664000175000017500000011250112623652600017464 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. All rights reserved. Copyright 2015 Garrett D'Amore 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 "../protocol.h" #include "../transport.h" #include "sock.h" #include "global.h" #include "ep.h" #include "../utils/err.h" #include "../utils/cont.h" #include "../utils/fast.h" #include "../utils/alloc.h" #include "../utils/msg.h" #include /* These bits specify whether individual efds are signalled or not at the moment. Storing this information allows us to avoid redundant signalling and unsignalling of the efd objects. */ #define NN_SOCK_FLAG_IN 1 #define NN_SOCK_FLAG_OUT 2 /* Possible states of the socket. */ #define NN_SOCK_STATE_INIT 1 #define NN_SOCK_STATE_ACTIVE 2 #define NN_SOCK_STATE_ZOMBIE 3 #define NN_SOCK_STATE_STOPPING_EPS 4 #define NN_SOCK_STATE_STOPPING 5 #define NN_SOCK_STATE_FINI 6 /* Events sent to the state machine. */ #define NN_SOCK_ACTION_ZOMBIFY 1 #define NN_SOCK_ACTION_STOPPED 2 /* Subordinated source objects. */ #define NN_SOCK_SRC_EP 1 /* Private functions. */ static struct nn_optset *nn_sock_optset (struct nn_sock *self, int id); static int nn_sock_setopt_inner (struct nn_sock *self, int level, int option, const void *optval, size_t optvallen); static void nn_sock_onleave (struct nn_ctx *self); static void nn_sock_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_sock_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_sock_action_zombify (struct nn_sock *self); /* Initialize a socket. A hold is placed on the initialized socket for the caller as well. */ int nn_sock_init (struct nn_sock *self, struct nn_socktype *socktype, int fd) { int rc; int i; /* Make sure that at least one message direction is supported. */ nn_assert (!(socktype->flags & NN_SOCKTYPE_FLAG_NOSEND) || !(socktype->flags & NN_SOCKTYPE_FLAG_NORECV)); /* Create the AIO context for the SP socket. */ nn_ctx_init (&self->ctx, nn_global_getpool (), nn_sock_onleave); /* Initialise the state machine. */ nn_fsm_init_root (&self->fsm, nn_sock_handler, nn_sock_shutdown, &self->ctx); self->state = NN_SOCK_STATE_INIT; /* Open the NN_SNDFD and NN_RCVFD efds. Do so, only if the socket type supports send/recv, as appropriate. */ if (socktype->flags & NN_SOCKTYPE_FLAG_NOSEND) memset (&self->sndfd, 0xcd, sizeof (self->sndfd)); else { rc = nn_efd_init (&self->sndfd); if (nn_slow (rc < 0)) return rc; } if (socktype->flags & NN_SOCKTYPE_FLAG_NORECV) memset (&self->rcvfd, 0xcd, sizeof (self->rcvfd)); else { rc = nn_efd_init (&self->rcvfd); if (nn_slow (rc < 0)) { if (!(socktype->flags & NN_SOCKTYPE_FLAG_NOSEND)) nn_efd_term (&self->sndfd); return rc; } } nn_sem_init (&self->termsem); nn_sem_init (&self->relesem); if (nn_slow (rc < 0)) { if (!(socktype->flags & NN_SOCKTYPE_FLAG_NORECV)) nn_efd_term (&self->rcvfd); if (!(socktype->flags & NN_SOCKTYPE_FLAG_NOSEND)) nn_efd_term (&self->sndfd); return rc; } self->holds = 1; /* Callers hold. */ self->flags = 0; nn_clock_init (&self->clock); nn_list_init (&self->eps); nn_list_init (&self->sdeps); self->eid = 1; /* Default values for NN_SOL_SOCKET options. */ self->linger = 1000; self->sndbuf = 128 * 1024; self->rcvbuf = 128 * 1024; self->rcvmaxsize = 1024 * 1024; self->sndtimeo = -1; self->rcvtimeo = -1; self->reconnect_ivl = 100; self->reconnect_ivl_max = 0; self->ep_template.sndprio = 8; self->ep_template.rcvprio = 8; self->ep_template.ipv4only = 1; /* Initialize statistic entries */ self->statistics.established_connections = 0; self->statistics.accepted_connections = 0; self->statistics.dropped_connections = 0; self->statistics.broken_connections = 0; self->statistics.connect_errors = 0; self->statistics.bind_errors = 0; self->statistics.accept_errors = 0; self->statistics.messages_sent = 0; self->statistics.messages_received = 0; self->statistics.bytes_sent = 0; self->statistics.bytes_received = 0; self->statistics.current_connections = 0; self->statistics.inprogress_connections = 0; self->statistics.current_snd_priority = 0; self->statistics.current_ep_errors = 0; /* Should be pretty much enough space for just the number */ sprintf(self->socket_name, "%d", fd); /* The transport-specific options are not initialised immediately, rather, they are allocated later on when needed. */ for (i = 0; i != NN_MAX_TRANSPORT; ++i) self->optsets [i] = NULL; /* Create the specific socket type itself. */ rc = socktype->create ((void*) self, &self->sockbase); errnum_assert (rc == 0, -rc); self->socktype = socktype; /* Launch the state machine. */ nn_ctx_enter (&self->ctx); nn_fsm_start (&self->fsm); nn_ctx_leave (&self->ctx); return 0; } void nn_sock_stopped (struct nn_sock *self) { /* TODO: Do the following in a more sane way. */ self->fsm.stopped.fsm = &self->fsm; self->fsm.stopped.src = NN_FSM_ACTION; self->fsm.stopped.srcptr = NULL; self->fsm.stopped.type = NN_SOCK_ACTION_STOPPED; nn_ctx_raise (self->fsm.ctx, &self->fsm.stopped); } void nn_sock_zombify (struct nn_sock *self) { nn_ctx_enter (&self->ctx); nn_fsm_action (&self->fsm, NN_SOCK_ACTION_ZOMBIFY); nn_ctx_leave (&self->ctx); } /* Stop the socket. This will prevent new calls from aquiring a hold on the socket, cause endpoints to shut down, and wake any threads waiting to recv or send data. */ void nn_sock_stop (struct nn_sock *self) { nn_ctx_enter (&self->ctx); nn_fsm_stop (&self->fsm); nn_ctx_leave (&self->ctx); } int nn_sock_term (struct nn_sock *self) { int rc; int i; /* NOTE: nn_sock_stop must have already been called. */ /* Some endpoints may still be alive. Here we are going to wait till they are all closed. This loop is not interruptible, because making it so would leave a partially cleaned up socket, and we don't have a way to defer resource deallocation. */ for (;;) { rc = nn_sem_wait (&self->termsem); if (nn_slow (rc == -EINTR)) continue; errnum_assert (rc == 0, -rc); break; } /* Also, wait for all holds on the socket to be released. */ for (;;) { rc = nn_sem_wait (&self->relesem); if (nn_slow (rc == -EINTR)) continue; errnum_assert (rc == 0, -rc); break; } /* Threads that posted the semaphore(s) can still have the ctx locked for a short while. By simply entering the context and exiting it immediately we can be sure that any such threads have already exited the context. */ nn_ctx_enter (&self->ctx); nn_ctx_leave (&self->ctx); /* At this point, we can be reasonably certain that no other thread has any references to the socket. */ nn_fsm_stopped_noevent (&self->fsm); nn_fsm_term (&self->fsm); nn_sem_term (&self->termsem); nn_list_term (&self->sdeps); nn_list_term (&self->eps); nn_clock_term (&self->clock); nn_ctx_term (&self->ctx); /* Destroy any optsets associated with the socket. */ for (i = 0; i != NN_MAX_TRANSPORT; ++i) if (self->optsets [i]) self->optsets [i]->vfptr->destroy (self->optsets [i]); return 0; } struct nn_ctx *nn_sock_getctx (struct nn_sock *self) { return &self->ctx; } int nn_sock_ispeer (struct nn_sock *self, int socktype) { /* If the peer implements a different SP protocol it is not a valid peer. Checking it here ensures that even if faulty protocol implementation allows for cross-protocol communication, it will never happen in practice. */ if ((self->socktype->protocol & 0xfff0) != (socktype & 0xfff0)) return 0; /* As long as the peer speaks the same protocol, socket type itself decides which socket types are to be accepted. */ return self->socktype->ispeer (socktype); } int nn_sock_setopt (struct nn_sock *self, int level, int option, const void *optval, size_t optvallen) { int rc; nn_ctx_enter (&self->ctx); if (nn_slow (self->state == NN_SOCK_STATE_ZOMBIE)) { nn_ctx_leave (&self->ctx); return -ETERM; } rc = nn_sock_setopt_inner (self, level, option, optval, optvallen); nn_ctx_leave (&self->ctx); return rc; } static int nn_sock_setopt_inner (struct nn_sock *self, int level, int option, const void *optval, size_t optvallen) { struct nn_optset *optset; int val; int *dst; /* Protocol-specific socket options. */ if (level > NN_SOL_SOCKET) return self->sockbase->vfptr->setopt (self->sockbase, level, option, optval, optvallen); /* Transport-specific options. */ if (level < NN_SOL_SOCKET) { optset = nn_sock_optset (self, level); if (!optset) return -ENOPROTOOPT; return optset->vfptr->setopt (optset, option, optval, optvallen); } /* Special-casing socket name for now as it's the only string option */ if (level == NN_SOL_SOCKET && option == NN_SOCKET_NAME) { if (optvallen > 63) return -EINVAL; memcpy (self->socket_name, optval, optvallen); self->socket_name [optvallen] = 0; return 0; } /* At this point we assume that all options are of type int. */ if (optvallen != sizeof (int)) return -EINVAL; val = *(int*) optval; /* Generic socket-level options. */ if (level == NN_SOL_SOCKET) { switch (option) { case NN_LINGER: dst = &self->linger; break; case NN_SNDBUF: if (nn_slow (val <= 0)) return -EINVAL; dst = &self->sndbuf; break; case NN_RCVBUF: if (nn_slow (val <= 0)) return -EINVAL; dst = &self->rcvbuf; break; case NN_RCVMAXSIZE: if (nn_slow (val < -1)) return -EINVAL; dst = &self->rcvmaxsize; break; case NN_SNDTIMEO: dst = &self->sndtimeo; break; case NN_RCVTIMEO: dst = &self->rcvtimeo; break; case NN_RECONNECT_IVL: if (nn_slow (val < 0)) return -EINVAL; dst = &self->reconnect_ivl; break; case NN_RECONNECT_IVL_MAX: if (nn_slow (val < 0)) return -EINVAL; dst = &self->reconnect_ivl_max; break; case NN_SNDPRIO: if (nn_slow (val < 1 || val > 16)) return -EINVAL; dst = &self->ep_template.sndprio; break; case NN_RCVPRIO: if (nn_slow (val < 1 || val > 16)) return -EINVAL; dst = &self->ep_template.rcvprio; break; case NN_IPV4ONLY: if (nn_slow (val != 0 && val != 1)) return -EINVAL; dst = &self->ep_template.ipv4only; break; default: return -ENOPROTOOPT; } *dst = val; return 0; } nn_assert (0); } int nn_sock_getopt (struct nn_sock *self, int level, int option, void *optval, size_t *optvallen) { int rc; nn_ctx_enter (&self->ctx); if (nn_slow (self->state == NN_SOCK_STATE_ZOMBIE)) { nn_ctx_leave (&self->ctx); return -ETERM; } rc = nn_sock_getopt_inner (self, level, option, optval, optvallen); nn_ctx_leave (&self->ctx); return rc; } int nn_sock_getopt_inner (struct nn_sock *self, int level, int option, void *optval, size_t *optvallen) { int rc; struct nn_optset *optset; int intval; nn_fd fd; /* Generic socket-level options. */ if (level == NN_SOL_SOCKET) { switch (option) { case NN_DOMAIN: intval = self->socktype->domain; break; case NN_PROTOCOL: intval = self->socktype->protocol; break; case NN_LINGER: intval = self->linger; break; case NN_SNDBUF: intval = self->sndbuf; break; case NN_RCVBUF: intval = self->rcvbuf; break; case NN_RCVMAXSIZE: intval = self->rcvmaxsize; break; case NN_SNDTIMEO: intval = self->sndtimeo; break; case NN_RCVTIMEO: intval = self->rcvtimeo; break; case NN_RECONNECT_IVL: intval = self->reconnect_ivl; break; case NN_RECONNECT_IVL_MAX: intval = self->reconnect_ivl_max; break; case NN_SNDPRIO: intval = self->ep_template.sndprio; break; case NN_RCVPRIO: intval = self->ep_template.rcvprio; break; case NN_IPV4ONLY: intval = self->ep_template.ipv4only; break; case NN_SNDFD: if (self->socktype->flags & NN_SOCKTYPE_FLAG_NOSEND) return -ENOPROTOOPT; fd = nn_efd_getfd (&self->sndfd); memcpy (optval, &fd, *optvallen < sizeof (nn_fd) ? *optvallen : sizeof (nn_fd)); *optvallen = sizeof (nn_fd); return 0; case NN_RCVFD: if (self->socktype->flags & NN_SOCKTYPE_FLAG_NORECV) return -ENOPROTOOPT; fd = nn_efd_getfd (&self->rcvfd); memcpy (optval, &fd, *optvallen < sizeof (nn_fd) ? *optvallen : sizeof (nn_fd)); *optvallen = sizeof (nn_fd); return 0; case NN_SOCKET_NAME: strncpy (optval, self->socket_name, *optvallen); *optvallen = strlen(self->socket_name); return 0; default: return -ENOPROTOOPT; } memcpy (optval, &intval, *optvallen < sizeof (int) ? *optvallen : sizeof (int)); *optvallen = sizeof (int); return 0; } /* Protocol-specific socket options. */ if (level > NN_SOL_SOCKET) return rc = self->sockbase->vfptr->getopt (self->sockbase, level, option, optval, optvallen); /* Transport-specific options. */ if (level < NN_SOL_SOCKET) { optset = nn_sock_optset (self, level); if (!optset) return -ENOPROTOOPT; return optset->vfptr->getopt (optset, option, optval, optvallen); } nn_assert (0); } int nn_sock_add_ep (struct nn_sock *self, struct nn_transport *transport, int bind, const char *addr) { int rc; struct nn_ep *ep; int eid; nn_ctx_enter (&self->ctx); /* Instantiate the endpoint. */ ep = nn_alloc (sizeof (struct nn_ep), "endpoint"); rc = nn_ep_init (ep, NN_SOCK_SRC_EP, self, self->eid, transport, bind, addr); if (nn_slow (rc < 0)) { nn_free (ep); nn_ctx_leave (&self->ctx); return rc; } nn_ep_start (ep); /* Increase the endpoint ID for the next endpoint. */ eid = self->eid; ++self->eid; /* Add it to the list of active endpoints. */ nn_list_insert (&self->eps, &ep->item, nn_list_end (&self->eps)); nn_ctx_leave (&self->ctx); return eid; } int nn_sock_rm_ep (struct nn_sock *self, int eid) { struct nn_list_item *it; struct nn_ep *ep; nn_ctx_enter (&self->ctx); /* Find the specified enpoint. */ ep = NULL; for (it = nn_list_begin (&self->eps); it != nn_list_end (&self->eps); it = nn_list_next (&self->eps, it)) { ep = nn_cont (it, struct nn_ep, item); if (ep->eid == eid) break; ep = NULL; } /* The endpoint doesn't exist. */ if (!ep) { nn_ctx_leave (&self->ctx); return -EINVAL; } /* Move the endpoint from the list of active endpoints to the list of shutting down endpoints. */ nn_list_erase (&self->eps, &ep->item); nn_list_insert (&self->sdeps, &ep->item, nn_list_end (&self->sdeps)); /* Ask the endpoint to stop. Actual terminatation may be delayed by the transport. */ nn_ep_stop (ep); nn_ctx_leave (&self->ctx); return 0; } int nn_sock_send (struct nn_sock *self, struct nn_msg *msg, int flags) { int rc; uint64_t deadline; uint64_t now; int timeout; /* Some sockets types cannot be used for sending messages. */ if (nn_slow (self->socktype->flags & NN_SOCKTYPE_FLAG_NOSEND)) return -ENOTSUP; nn_ctx_enter (&self->ctx); /* Compute the deadline for SNDTIMEO timer. */ if (self->sndtimeo < 0) { deadline = -1; timeout = -1; } else { deadline = nn_clock_now (&self->clock) + self->sndtimeo; timeout = self->sndtimeo; } while (1) { switch (self->state) { case NN_SOCK_STATE_ACTIVE: case NN_SOCK_STATE_INIT: break; case NN_SOCK_STATE_ZOMBIE: /* If nn_term() was already called, return ETERM. */ nn_ctx_leave (&self->ctx); return -ETERM; case NN_SOCK_STATE_STOPPING_EPS: case NN_SOCK_STATE_STOPPING: case NN_SOCK_STATE_FINI: /* Socket closed or closing. Should we return something else here; recvmsg(2) for example returns no data in this case, like read(2). The use of indexed file descriptors is further problematic, as an FD can be reused leading to situations where technically the outstanding operation should refer to some other socket entirely. */ nn_ctx_leave (&self->ctx); return -EBADF; } /* Try to send the message in a non-blocking way. */ rc = self->sockbase->vfptr->send (self->sockbase, msg); if (nn_fast (rc == 0)) { nn_ctx_leave (&self->ctx); return 0; } nn_assert (rc < 0); /* Any unexpected error is forwarded to the caller. */ if (nn_slow (rc != -EAGAIN)) { nn_ctx_leave (&self->ctx); return rc; } /* If the message cannot be sent at the moment and the send call is non-blocking, return immediately. */ if (nn_fast (flags & NN_DONTWAIT)) { nn_ctx_leave (&self->ctx); return -EAGAIN; } /* With blocking send, wait while there are new pipes available for sending. */ nn_ctx_leave (&self->ctx); rc = nn_efd_wait (&self->sndfd, timeout); if (nn_slow (rc == -ETIMEDOUT)) return -ETIMEDOUT; if (nn_slow (rc == -EINTR)) return -EINTR; if (nn_slow (rc == -EBADF)) return -EBADF; errnum_assert (rc == 0, rc); nn_ctx_enter (&self->ctx); /* * Double check if pipes are still available for sending */ if (!nn_efd_wait (&self->sndfd, 0)) { self->flags |= NN_SOCK_FLAG_OUT; } /* If needed, re-compute the timeout to reflect the time that have already elapsed. */ if (self->sndtimeo >= 0) { now = nn_clock_now (&self->clock); timeout = (int) (now > deadline ? 0 : deadline - now); } } } int nn_sock_recv (struct nn_sock *self, struct nn_msg *msg, int flags) { int rc; uint64_t deadline; uint64_t now; int timeout; /* Some sockets types cannot be used for receiving messages. */ if (nn_slow (self->socktype->flags & NN_SOCKTYPE_FLAG_NORECV)) return -ENOTSUP; nn_ctx_enter (&self->ctx); /* Compute the deadline for RCVTIMEO timer. */ if (self->rcvtimeo < 0) { deadline = -1; timeout = -1; } else { deadline = nn_clock_now (&self->clock) + self->rcvtimeo; timeout = self->rcvtimeo; } while (1) { switch (self->state) { case NN_SOCK_STATE_ACTIVE: case NN_SOCK_STATE_INIT: break; case NN_SOCK_STATE_ZOMBIE: /* If nn_term() was already called, return ETERM. */ nn_ctx_leave (&self->ctx); return -ETERM; case NN_SOCK_STATE_STOPPING_EPS: case NN_SOCK_STATE_STOPPING: case NN_SOCK_STATE_FINI: /* Socket closed or closing. Should we return something else here; recvmsg(2) for example returns no data in this case, like read(2). The use of indexed file descriptors is further problematic, as an FD can be reused leading to situations where technically the outstanding operation should refer to some other socket entirely. */ nn_ctx_leave (&self->ctx); return -EBADF; } /* Try to receive the message in a non-blocking way. */ rc = self->sockbase->vfptr->recv (self->sockbase, msg); if (nn_fast (rc == 0)) { nn_ctx_leave (&self->ctx); return 0; } nn_assert (rc < 0); /* Any unexpected error is forwarded to the caller. */ if (nn_slow (rc != -EAGAIN)) { nn_ctx_leave (&self->ctx); return rc; } /* If the message cannot be received at the moment and the recv call is non-blocking, return immediately. */ if (nn_fast (flags & NN_DONTWAIT)) { nn_ctx_leave (&self->ctx); return -EAGAIN; } /* With blocking recv, wait while there are new pipes available for receiving. */ nn_ctx_leave (&self->ctx); rc = nn_efd_wait (&self->rcvfd, timeout); if (nn_slow (rc == -ETIMEDOUT)) return -ETIMEDOUT; if (nn_slow (rc == -EINTR)) return -EINTR; if (nn_slow (rc == -EBADF)) return -EBADF; errnum_assert (rc == 0, rc); nn_ctx_enter (&self->ctx); /* * Double check if pipes are still available for receiving */ if (!nn_efd_wait (&self->rcvfd, 0)) { self->flags |= NN_SOCK_FLAG_IN; } /* If needed, re-compute the timeout to reflect the time that have already elapsed. */ if (self->rcvtimeo >= 0) { now = nn_clock_now (&self->clock); timeout = (int) (now > deadline ? 0 : deadline - now); } } } int nn_sock_add (struct nn_sock *self, struct nn_pipe *pipe) { int rc; rc = self->sockbase->vfptr->add (self->sockbase, pipe); if (nn_slow (rc >= 0)) { nn_sock_stat_increment (self, NN_STAT_CURRENT_CONNECTIONS, 1); } return rc; } void nn_sock_rm (struct nn_sock *self, struct nn_pipe *pipe) { self->sockbase->vfptr->rm (self->sockbase, pipe); nn_sock_stat_increment (self, NN_STAT_CURRENT_CONNECTIONS, -1); } static void nn_sock_onleave (struct nn_ctx *self) { struct nn_sock *sock; int events; sock = nn_cont (self, struct nn_sock, ctx); /* If nn_close() was already called there's no point in adjusting the snd/rcv file descriptors. */ if (nn_slow (sock->state != NN_SOCK_STATE_ACTIVE)) return; /* Check whether socket is readable and/or writable at the moment. */ events = sock->sockbase->vfptr->events (sock->sockbase); errnum_assert (events >= 0, -events); /* Signal/unsignal IN as needed. */ if (!(sock->socktype->flags & NN_SOCKTYPE_FLAG_NORECV)) { if (events & NN_SOCKBASE_EVENT_IN) { if (!(sock->flags & NN_SOCK_FLAG_IN)) { sock->flags |= NN_SOCK_FLAG_IN; nn_efd_signal (&sock->rcvfd); } } else { if (sock->flags & NN_SOCK_FLAG_IN) { sock->flags &= ~NN_SOCK_FLAG_IN; nn_efd_unsignal (&sock->rcvfd); } } } /* Signal/unsignal OUT as needed. */ if (!(sock->socktype->flags & NN_SOCKTYPE_FLAG_NOSEND)) { if (events & NN_SOCKBASE_EVENT_OUT) { if (!(sock->flags & NN_SOCK_FLAG_OUT)) { sock->flags |= NN_SOCK_FLAG_OUT; nn_efd_signal (&sock->sndfd); } } else { if (sock->flags & NN_SOCK_FLAG_OUT) { sock->flags &= ~NN_SOCK_FLAG_OUT; nn_efd_unsignal (&sock->sndfd); } } } } static struct nn_optset *nn_sock_optset (struct nn_sock *self, int id) { int index; struct nn_transport *tp; /* Transport IDs are negative and start from -1. */ index = (-id) - 1; /* Check for invalid indices. */ if (nn_slow (index < 0 || index >= NN_MAX_TRANSPORT)) return NULL; /* If the option set already exists return it. */ if (nn_fast (self->optsets [index] != NULL)) return self->optsets [index]; /* If the option set doesn't exist yet, create it. */ tp = nn_global_transport (id); if (nn_slow (!tp)) return NULL; if (nn_slow (!tp->optset)) return NULL; self->optsets [index] = tp->optset (); return self->optsets [index]; } static void nn_sock_shutdown (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_sock *sock; struct nn_list_item *it; struct nn_ep *ep; sock = nn_cont (self, struct nn_sock, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { nn_assert (sock->state == NN_SOCK_STATE_ACTIVE || sock->state == NN_SOCK_STATE_ZOMBIE); /* Close sndfd and rcvfd. This should make any current select/poll using SNDFD and/or RCVFD exit. */ if (!(sock->socktype->flags & NN_SOCKTYPE_FLAG_NORECV)) { nn_efd_stop (&sock->rcvfd); } if (!(sock->socktype->flags & NN_SOCKTYPE_FLAG_NOSEND)) { nn_efd_stop (&sock->sndfd); } /* Ask all the associated endpoints to stop. */ it = nn_list_begin (&sock->eps); while (it != nn_list_end (&sock->eps)) { ep = nn_cont (it, struct nn_ep, item); it = nn_list_next (&sock->eps, it); nn_list_erase (&sock->eps, &ep->item); nn_list_insert (&sock->sdeps, &ep->item, nn_list_end (&sock->sdeps)); nn_ep_stop (ep); } sock->state = NN_SOCK_STATE_STOPPING_EPS; goto finish2; } if (nn_slow (sock->state == NN_SOCK_STATE_STOPPING_EPS)) { if (!(src == NN_SOCK_SRC_EP && type == NN_EP_STOPPED)) { /* If we got here waiting for EPs to teardown, but src is not an EP, then it isn't safe for us to do anything, because we just need to wait for the EPs to finish up their thing. Just bail. */ return; } /* Endpoint is stopped. Now we can safely deallocate it. */ ep = (struct nn_ep*) srcptr; nn_list_erase (&sock->sdeps, &ep->item); nn_ep_term (ep); nn_free (ep); finish2: /* If all the endpoints are deallocated, we can start stopping protocol-specific part of the socket. If there' no stop function we can consider it stopped straight away. */ if (!nn_list_empty (&sock->sdeps)) return; nn_assert (nn_list_empty (&sock->eps)); sock->state = NN_SOCK_STATE_STOPPING; if (!sock->sockbase->vfptr->stop) goto finish1; sock->sockbase->vfptr->stop (sock->sockbase); return; } if (nn_slow (sock->state == NN_SOCK_STATE_STOPPING)) { /* We get here when the deallocation of the socket was delayed by the specific socket type. */ nn_assert (src == NN_FSM_ACTION && type == NN_SOCK_ACTION_STOPPED); finish1: /* Protocol-specific part of the socket is stopped. We can safely deallocate it. */ sock->sockbase->vfptr->destroy (sock->sockbase); sock->state = NN_SOCK_STATE_FINI; /* Close the event FDs entirely. */ if (!(sock->socktype->flags & NN_SOCKTYPE_FLAG_NORECV)) { nn_efd_term (&sock->rcvfd); } if (!(sock->socktype->flags & NN_SOCKTYPE_FLAG_NOSEND)) { nn_efd_term (&sock->sndfd); } /* Now we can unblock the application thread blocked in the nn_close() call. */ nn_sem_post (&sock->termsem); return; } nn_fsm_bad_state(sock->state, src, type); } static void nn_sock_handler (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_sock *sock; struct nn_ep *ep; sock = nn_cont (self, struct nn_sock, fsm); switch (sock->state) { /******************************************************************************/ /* INIT state. */ /******************************************************************************/ case NN_SOCK_STATE_INIT: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: sock->state = NN_SOCK_STATE_ACTIVE; return; case NN_SOCK_ACTION_ZOMBIFY: nn_sock_action_zombify (sock); return; default: nn_fsm_bad_action (sock->state, src, type); } default: nn_fsm_bad_source (sock->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /******************************************************************************/ case NN_SOCK_STATE_ACTIVE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_SOCK_ACTION_ZOMBIFY: nn_sock_action_zombify (sock); return; default: nn_fsm_bad_action (sock->state, src, type); } case NN_SOCK_SRC_EP: switch (type) { case NN_EP_STOPPED: /* This happens when an endpoint is closed using nn_shutdown() function. */ ep = (struct nn_ep*) srcptr; nn_list_erase (&sock->sdeps, &ep->item); nn_ep_term (ep); nn_free (ep); return; default: nn_fsm_bad_action (sock->state, src, type); } default: /* The assumption is that all the other events come from pipes. */ switch (type) { case NN_PIPE_IN: sock->sockbase->vfptr->in (sock->sockbase, (struct nn_pipe*) srcptr); return; case NN_PIPE_OUT: sock->sockbase->vfptr->out (sock->sockbase, (struct nn_pipe*) srcptr); return; default: nn_fsm_bad_action (sock->state, src, type); } } /******************************************************************************/ /* ZOMBIE state. */ /******************************************************************************/ case NN_SOCK_STATE_ZOMBIE: nn_fsm_bad_state (sock->state, src, type); /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (sock->state, src, type); } } /******************************************************************************/ /* State machine actions. */ /******************************************************************************/ static void nn_sock_action_zombify (struct nn_sock *self) { /* Switch to the zombie state. From now on all the socket functions will return ETERM. */ self->state = NN_SOCK_STATE_ZOMBIE; /* Set IN and OUT events to unblock any polling function. */ if (!(self->flags & NN_SOCK_FLAG_IN)) { self->flags |= NN_SOCK_FLAG_IN; if (!(self->socktype->flags & NN_SOCKTYPE_FLAG_NORECV)) nn_efd_signal (&self->rcvfd); } if (!(self->flags & NN_SOCK_FLAG_OUT)) { self->flags |= NN_SOCK_FLAG_OUT; if (!(self->socktype->flags & NN_SOCKTYPE_FLAG_NOSEND)) nn_efd_signal (&self->sndfd); } } void nn_sock_report_error (struct nn_sock *self, struct nn_ep *ep, int errnum) { if (!nn_global_print_errors()) return; if (errnum == 0) return; if (ep) { fprintf(stderr, "nanomsg: socket.%s[%s]: Error: %s\n", self->socket_name, nn_ep_getaddr(ep), nn_strerror(errnum)); } else { fprintf(stderr, "nanomsg: socket.%s: Error: %s\n", self->socket_name, nn_strerror(errnum)); } } void nn_sock_stat_increment (struct nn_sock *self, int name, int64_t increment) { switch (name) { case NN_STAT_ESTABLISHED_CONNECTIONS: nn_assert (increment > 0); self->statistics.established_connections += increment; break; case NN_STAT_ACCEPTED_CONNECTIONS: nn_assert (increment > 0); self->statistics.accepted_connections += increment; break; case NN_STAT_DROPPED_CONNECTIONS: nn_assert (increment > 0); self->statistics.dropped_connections += increment; break; case NN_STAT_BROKEN_CONNECTIONS: nn_assert (increment > 0); self->statistics.broken_connections += increment; break; case NN_STAT_CONNECT_ERRORS: nn_assert (increment > 0); self->statistics.connect_errors += increment; break; case NN_STAT_BIND_ERRORS: nn_assert (increment > 0); self->statistics.bind_errors += increment; break; case NN_STAT_ACCEPT_ERRORS: nn_assert (increment > 0); self->statistics.accept_errors += increment; break; case NN_STAT_MESSAGES_SENT: nn_assert (increment > 0); self->statistics.messages_sent += increment; break; case NN_STAT_MESSAGES_RECEIVED: nn_assert (increment > 0); self->statistics.messages_received += increment; break; case NN_STAT_BYTES_SENT: nn_assert (increment >= 0); self->statistics.bytes_sent += increment; break; case NN_STAT_BYTES_RECEIVED: nn_assert (increment >= 0); self->statistics.bytes_received += increment; break; case NN_STAT_CURRENT_CONNECTIONS: nn_assert (increment > 0 || self->statistics.current_connections >= -increment); nn_assert(increment < INT_MAX && increment > -INT_MAX); self->statistics.current_connections += (int) increment; break; case NN_STAT_INPROGRESS_CONNECTIONS: nn_assert (increment > 0 || self->statistics.inprogress_connections >= -increment); nn_assert(increment < INT_MAX && increment > -INT_MAX); self->statistics.inprogress_connections += (int) increment; break; case NN_STAT_CURRENT_SND_PRIORITY: /* This is an exception, we don't want to increment priority */ nn_assert((increment > 0 && increment <= 16) || increment == -1); self->statistics.current_snd_priority = (int) increment; break; case NN_STAT_CURRENT_EP_ERRORS: nn_assert (increment > 0 || self->statistics.current_ep_errors >= -increment); nn_assert(increment < INT_MAX && increment > -INT_MAX); self->statistics.current_ep_errors += (int) increment; break; } } int nn_sock_hold (struct nn_sock *self) { switch (self->state) { case NN_SOCK_STATE_ACTIVE: case NN_SOCK_STATE_INIT: self->holds++; return 0; case NN_SOCK_STATE_ZOMBIE: return -ETERM; case NN_SOCK_STATE_STOPPING: case NN_SOCK_STATE_STOPPING_EPS: case NN_SOCK_STATE_FINI: default: return -EBADF; } } void nn_sock_rele (struct nn_sock *self) { self->holds--; if (self->holds == 0) { nn_sem_post (&self->relesem); } } nanomsg-0.8-beta/src/core/sockbase.c0000664000175000017500000000376412623652600020331 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "../protocol.h" #include "sock.h" #include "../utils/err.h" #include "../utils/attr.h" void nn_sockbase_init (struct nn_sockbase *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { self->vfptr = vfptr; self->sock = (struct nn_sock*) hint; } void nn_sockbase_term (NN_UNUSED struct nn_sockbase *self) { } void nn_sockbase_stopped (struct nn_sockbase *self) { nn_sock_stopped (self->sock); } struct nn_ctx *nn_sockbase_getctx (struct nn_sockbase *self) { return nn_sock_getctx (self->sock); } int nn_sockbase_getopt (struct nn_sockbase *self, int option, void *optval, size_t *optvallen) { return nn_sock_getopt_inner (self->sock, NN_SOL_SOCKET, option, optval, optvallen); } void nn_sockbase_stat_increment (struct nn_sockbase *self, int name, int increment) { nn_sock_stat_increment (self->sock, name, increment); } nanomsg-0.8-beta/src/core/symbol.c0000664000175000017500000002436712623652600020046 0ustar00travistravis00000000000000/* Copyright (c) 2013 Evan Wies Copyright (c) 2013 GoPivotal, Inc. 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 "../nn.h" #include "../inproc.h" #include "../ipc.h" #include "../tcp.h" #include "../pair.h" #include "../pubsub.h" #include "../reqrep.h" #include "../pipeline.h" #include "../survey.h" #include "../bus.h" #include static const struct nn_symbol_properties sym_value_names [] = { {NN_NS_NAMESPACE, "NN_NS_NAMESPACE", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_NS_VERSION, "NN_NS_VERSION", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_NS_DOMAIN, "NN_NS_DOMAIN", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_NS_TRANSPORT, "NN_NS_TRANSPORT", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_NS_PROTOCOL, "NN_NS_PROTOCOL", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_NS_OPTION_LEVEL, "NN_NS_OPTION_LEVEL", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_NS_SOCKET_OPTION, "NN_NS_SOCKET_OPTION", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_NS_TRANSPORT_OPTION, "NN_NS_TRANSPORT_OPTION", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_NS_OPTION_TYPE, "NN_NS_OPTION_TYPE", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_NS_OPTION_UNIT, "NN_NS_OPTION_UNIT", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_NS_FLAG, "NN_NS_FLAG", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_NS_ERROR, "NN_NS_ERROR", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_NS_LIMIT, "NN_NS_LIMIT", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_NS_EVENT, "NN_NS_EVENT", NN_NS_NAMESPACE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_TYPE_NONE, "NN_TYPE_NONE", NN_NS_OPTION_TYPE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_TYPE_INT, "NN_TYPE_INT", NN_NS_OPTION_TYPE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_TYPE_STR, "NN_TYPE_STR", NN_NS_OPTION_TYPE, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_UNIT_NONE, "NN_UNIT_NONE", NN_NS_OPTION_UNIT, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_UNIT_BYTES, "NN_UNIT_BYTES", NN_NS_OPTION_UNIT, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_UNIT_MILLISECONDS, "NN_UNIT_MILLISECONDS", NN_NS_OPTION_UNIT, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_UNIT_PRIORITY, "NN_UNIT_PRIORITY", NN_NS_OPTION_UNIT, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_UNIT_BOOLEAN, "NN_UNIT_BOOLEAN", NN_NS_OPTION_UNIT, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_VERSION_CURRENT, "NN_VERSION_CURRENT", NN_NS_VERSION, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_VERSION_REVISION, "NN_VERSION_REVISION", NN_NS_VERSION, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_VERSION_AGE, "NN_VERSION_AGE", NN_NS_VERSION, NN_TYPE_NONE, NN_UNIT_NONE}, {AF_SP, "AF_SP", NN_NS_DOMAIN, NN_TYPE_NONE, NN_UNIT_NONE}, {AF_SP_RAW, "AF_SP_RAW", NN_NS_DOMAIN, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_INPROC, "NN_INPROC", NN_NS_TRANSPORT, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_IPC, "NN_IPC", NN_NS_TRANSPORT, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_TCP, "NN_TCP", NN_NS_TRANSPORT, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_PAIR, "NN_PAIR", NN_NS_PROTOCOL, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_PUB, "NN_PUB", NN_NS_PROTOCOL, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_SUB, "NN_SUB", NN_NS_PROTOCOL, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_REP, "NN_REP", NN_NS_PROTOCOL, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_REQ, "NN_REQ", NN_NS_PROTOCOL, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_PUSH, "NN_PUSH", NN_NS_PROTOCOL, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_PULL, "NN_PULL", NN_NS_PROTOCOL, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_SURVEYOR, "NN_SURVEYOR", NN_NS_PROTOCOL, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_RESPONDENT, "NN_RESPONDENT", NN_NS_PROTOCOL, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_BUS, "NN_BUS", NN_NS_PROTOCOL, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_SOCKADDR_MAX, "NN_SOCKADDR_MAX", NN_NS_LIMIT, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_SOL_SOCKET, "NN_SOL_SOCKET", NN_NS_OPTION_LEVEL, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_LINGER, "NN_LINGER", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_MILLISECONDS}, {NN_SNDBUF, "NN_SNDBUF", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_BYTES}, {NN_RCVBUF, "NN_RCVBUF", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_BYTES}, {NN_RCVMAXSIZE, "NN_RCVMAXSIZE", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_BYTES}, {NN_SNDTIMEO, "NN_SNDTIMEO", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_MILLISECONDS}, {NN_RCVTIMEO, "NN_RCVTIMEO", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_MILLISECONDS}, {NN_RECONNECT_IVL, "NN_RECONNECT_IVL", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_MILLISECONDS}, {NN_RECONNECT_IVL_MAX, "NN_RECONNECT_IVL_MAX", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_MILLISECONDS}, {NN_SNDPRIO, "NN_SNDPRIO", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_PRIORITY}, {NN_RCVPRIO, "NN_RCVPRIO", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_PRIORITY}, {NN_SNDFD, "NN_SNDFD", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_NONE}, {NN_RCVFD, "NN_RCVFD", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_NONE}, {NN_DOMAIN, "NN_DOMAIN", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_NONE}, {NN_PROTOCOL, "NN_PROTOCOL", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_NONE}, {NN_IPV4ONLY, "NN_IPV4ONLY", NN_NS_SOCKET_OPTION, NN_TYPE_INT, NN_UNIT_BOOLEAN}, {NN_SOCKET_NAME, "NN_SOCKET_NAME", NN_NS_SOCKET_OPTION, NN_TYPE_STR, NN_UNIT_NONE}, {NN_SUB_SUBSCRIBE, "NN_SUB_SUBSCRIBE", NN_NS_TRANSPORT_OPTION, NN_TYPE_STR, NN_UNIT_NONE}, {NN_SUB_UNSUBSCRIBE, "NN_SUB_UNSUBSCRIBE", NN_NS_TRANSPORT_OPTION, NN_TYPE_STR, NN_UNIT_NONE}, {NN_REQ_RESEND_IVL, "NN_REQ_RESEND_IVL", NN_NS_TRANSPORT_OPTION, NN_TYPE_INT, NN_UNIT_MILLISECONDS}, {NN_SURVEYOR_DEADLINE, "NN_SURVEYOR_DEADLINE", NN_NS_TRANSPORT_OPTION, NN_TYPE_INT, NN_UNIT_MILLISECONDS}, {NN_TCP_NODELAY, "NN_TCP_NODELAY", NN_NS_TRANSPORT_OPTION, NN_TYPE_INT, NN_UNIT_BOOLEAN}, {NN_DONTWAIT, "NN_DONTWAIT", NN_NS_FLAG, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_POLLIN, "NN_POLLIN", NN_NS_EVENT, NN_TYPE_NONE, NN_UNIT_NONE}, {NN_POLLOUT, "NN_POLLOUT", NN_NS_EVENT, NN_TYPE_NONE, NN_UNIT_NONE}, {EADDRINUSE, "EADDRINUSE", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EADDRNOTAVAIL, "EADDRNOTAVAIL", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EAFNOSUPPORT, "EAFNOSUPPORT", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EAGAIN, "EAGAIN", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EBADF, "EBADF", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ECONNREFUSED, "ECONNREFUSED", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EFAULT, "EFAULT", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EFSM, "EFSM", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EINPROGRESS, "EINPROGRESS", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EINTR, "EINTR", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EINVAL, "EINVAL", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EMFILE, "EMFILE", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ENAMETOOLONG, "ENAMETOOLONG", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ENETDOWN, "ENETDOWN", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ENOBUFS, "ENOBUFS", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ENODEV, "ENODEV", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ENOMEM, "ENOMEM", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ENOPROTOOPT, "ENOPROTOOPT", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ENOTSOCK, "ENOTSOCK", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ENOTSUP, "ENOTSUP", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EPROTO, "EPROTO", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EPROTONOSUPPORT, "EPROTONOSUPPORT", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ETERM, "ETERM", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ETIMEDOUT, "ETIMEDOUT", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EACCES, "EACCES" , NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ECONNABORTED, "ECONNABORTED", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ECONNRESET, "ECONNRESET", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EHOSTUNREACH, "EHOSTUNREACH", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {EMSGSIZE, "EMSGSIZE", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ENETRESET, "ENETRESET", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ENETUNREACH, "ENETUNREACH", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, {ENOTCONN, "ENOTCONN", NN_NS_ERROR, NN_TYPE_NONE, NN_UNIT_NONE}, }; const int SYM_VALUE_NAMES_LEN = (sizeof (sym_value_names) / sizeof (sym_value_names [0])); const char *nn_symbol (int i, int *value) { const struct nn_symbol_properties *svn; if (i < 0 || i >= SYM_VALUE_NAMES_LEN) { errno = EINVAL; return NULL; } svn = &sym_value_names [i]; if (value) *value = svn->value; return svn->name; } int nn_symbol_info (int i, struct nn_symbol_properties *buf, int buflen) { if (i < 0 || i >= SYM_VALUE_NAMES_LEN) { return 0; } if (buflen > (int)sizeof (struct nn_symbol_properties)) { buflen = (int)sizeof (struct nn_symbol_properties); } memcpy(buf, &sym_value_names [i], buflen); return buflen; } nanomsg-0.8-beta/src/devices/0000775000175000017500000000000012623652617017063 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/devices/device.c0000664000175000017500000002663012623652600020465 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "../nn.h" #include "../utils/err.h" #include "../utils/fast.h" #include "../utils/fd.h" #include "../utils/attr.h" #include "device.h" #include #if defined NN_HAVE_WINDOWS #include "../utils/win.h" #elif defined NN_HAVE_POLL #include #else #error #endif int nn_custom_device(struct nn_device_recipe *device, int s1, int s2, int flags) { return nn_device_entry (device, s1, s2, flags); } int nn_device (int s1, int s2) { return nn_custom_device (&nn_ordinary_device, s1, s2, 0); } int nn_device_entry (struct nn_device_recipe *device, int s1, int s2, NN_UNUSED int flags) { int rc; int op1; int op2; nn_fd s1rcv; nn_fd s1snd; nn_fd s2rcv; nn_fd s2snd; size_t opsz; /* At least one socket must be specified. */ if (device->required_checks & NN_CHECK_AT_LEAST_ONE_SOCKET) { if (s1 < 0 && s2 < 0) { errno = EBADF; return -1; } } /* Handle the case when there's only one socket in the device. */ if (device->required_checks & NN_CHECK_ALLOW_LOOPBACK) { if (s2 < 0) return nn_device_loopback (device,s1); if (s1 < 0) return nn_device_loopback (device,s2); } /* Check whether both sockets are "raw" sockets. */ if (device->required_checks & NN_CHECK_REQUIRE_RAW_SOCKETS) { opsz = sizeof (op1); rc = nn_getsockopt (s1, NN_SOL_SOCKET, NN_DOMAIN, &op1, &opsz); errno_assert (rc == 0); nn_assert (opsz == sizeof (op1)); opsz = sizeof (op2); rc = nn_getsockopt (s2, NN_SOL_SOCKET, NN_DOMAIN, &op2, &opsz); errno_assert (rc == 0); nn_assert (opsz == sizeof (op2)); if (op1 != AF_SP_RAW || op2 != AF_SP_RAW) { errno = EINVAL; return -1; } } /* Check whether both sockets are from the same protocol. */ if (device->required_checks & NN_CHECK_SAME_PROTOCOL_FAMILY) { opsz = sizeof (op1); rc = nn_getsockopt (s1, NN_SOL_SOCKET, NN_PROTOCOL, &op1, &opsz); errno_assert (rc == 0); nn_assert (opsz == sizeof (op1)); opsz = sizeof (op2); rc = nn_getsockopt (s2, NN_SOL_SOCKET, NN_PROTOCOL, &op2, &opsz); errno_assert (rc == 0); nn_assert (opsz == sizeof (op2)); if (op1 / 16 != op2 / 16) { errno = EINVAL; return -1; } } /* Get the file descriptors for polling. */ opsz = sizeof (s1rcv); rc = nn_getsockopt (s1, NN_SOL_SOCKET, NN_RCVFD, &s1rcv, &opsz); if (rc < 0 && nn_errno () == ENOPROTOOPT) s1rcv = -1; else { nn_assert (rc == 0); nn_assert (opsz == sizeof (s1rcv)); nn_assert (s1rcv >= 0); } opsz = sizeof (s1snd); rc = nn_getsockopt (s1, NN_SOL_SOCKET, NN_SNDFD, &s1snd, &opsz); if (rc < 0 && nn_errno () == ENOPROTOOPT) s1snd = -1; else { nn_assert (rc == 0); nn_assert (opsz == sizeof (s1snd)); nn_assert (s1snd >= 0); } opsz = sizeof (s2rcv); rc = nn_getsockopt (s2, NN_SOL_SOCKET, NN_RCVFD, &s2rcv, &opsz); if (rc < 0 && nn_errno () == ENOPROTOOPT) s2rcv = -1; else { nn_assert (rc == 0); nn_assert (opsz == sizeof (s2rcv)); nn_assert (s2rcv >= 0); } opsz = sizeof (s2snd); rc = nn_getsockopt (s2, NN_SOL_SOCKET, NN_SNDFD, &s2snd, &opsz); if (rc < 0 && nn_errno () == ENOPROTOOPT) s2snd = -1; else { nn_assert (rc == 0); nn_assert (opsz == sizeof (s2snd)); nn_assert (s2snd >= 0); } if (device->required_checks & NN_CHECK_SOCKET_DIRECTIONALITY) { /* Check the directionality of the sockets. */ if (s1rcv != -1 && s2snd == -1) { errno = EINVAL; return -1; } if (s1snd != -1 && s2rcv == -1) { errno = EINVAL; return -1; } if (s2rcv != -1 && s1snd == -1) { errno = EINVAL; return -1; } if (s2snd != -1 && s1rcv == -1) { errno = EINVAL; return -1; } } /* Two-directional device. */ if (device->required_checks & NN_CHECK_ALLOW_BIDIRECTIONAL) { if (s1rcv != -1 && s1snd != -1 && s2rcv != -1 && s2snd != -1) return nn_device_twoway (device, s1, s1rcv, s1snd, s2, s2rcv, s2snd); } if (device->required_checks & NN_CHECK_ALLOW_UNIDIRECTIONAL) { /* Single-directional device passing messages from s1 to s2. */ if (s1rcv != -1 && s1snd == -1 && s2rcv == -1 && s2snd != -1) return nn_device_oneway (device,s1, s1rcv, s2, s2snd); /* Single-directional device passing messages from s2 to s1. */ if (s1rcv == -1 && s1snd != -1 && s2rcv != -1 && s2snd == -1) return nn_device_oneway (device,s2, s2rcv, s1, s1snd); } /* This should never happen. */ nn_assert (0); } int nn_device_loopback (struct nn_device_recipe *device, int s) { int rc; int op; size_t opsz; /* Check whether the socket is a "raw" socket. */ opsz = sizeof (op); rc = nn_getsockopt (s, NN_SOL_SOCKET, NN_DOMAIN, &op, &opsz); errno_assert (rc == 0); nn_assert (opsz == sizeof (op)); if (op != AF_SP_RAW) { errno = EINVAL; return -1; } while (1) { rc = nn_device_mvmsg (device,s, s, 0); if (nn_slow (rc < 0)) return -1; } } #if defined NN_HAVE_WINDOWS int nn_device_twoway (struct nn_device_recipe *device, int s1, nn_fd s1rcv, nn_fd s1snd, int s2, nn_fd s2rcv, nn_fd s2snd) { int rc; fd_set fds; int s1rcv_isready = 0; int s1snd_isready = 0; int s2rcv_isready = 0; int s2snd_isready = 0; /* Initialise the pollset. */ FD_ZERO (&fds); while (1) { /* Wait for network events. Adjust the 'ready' events based on the result. */ if (s1rcv_isready) FD_CLR (s1rcv, &fds); else FD_SET (s1rcv, &fds); if (s1snd_isready) FD_CLR (s1snd, &fds); else FD_SET (s1snd, &fds); if (s2rcv_isready) FD_CLR (s2rcv, &fds); else FD_SET (s2rcv, &fds); if (s2snd_isready) FD_CLR (s2snd, &fds); else FD_SET (s2snd, &fds); rc = select (0, &fds, NULL, NULL, NULL); wsa_assert (rc != SOCKET_ERROR); if (FD_ISSET (s1rcv, &fds)) s1rcv_isready = 1; if (FD_ISSET (s1snd, &fds)) s1snd_isready = 1; if (FD_ISSET (s2rcv, &fds)) s2rcv_isready = 1; if (FD_ISSET (s2snd, &fds)) s2snd_isready = 1; /* If possible, pass the message from s1 to s2. */ if (s1rcv_isready && s2snd_isready) { rc = nn_device_mvmsg (device,s1, s2, NN_DONTWAIT); if (nn_slow (rc < 0)) return -1; s1rcv_isready = 0; s2snd_isready = 0; } /* If possible, pass the message from s2 to s1. */ if (s2rcv_isready && s1snd_isready) { rc = nn_device_mvmsg (device,s2, s1, NN_DONTWAIT); if (nn_slow (rc < 0)) return -1; s2rcv_isready = 0; s1snd_isready = 0; } } } #elif defined NN_HAVE_POLL int nn_device_twoway (struct nn_device_recipe *device, int s1, nn_fd s1rcv, nn_fd s1snd, int s2, nn_fd s2rcv, nn_fd s2snd) { int rc; struct pollfd pfd [4]; /* Initialise the pollset. */ pfd [0].fd = s1rcv; pfd [0].events = POLLIN; pfd [1].fd = s1snd; pfd [1].events = POLLIN; pfd [2].fd = s2rcv; pfd [2].events = POLLIN; pfd [3].fd = s2snd; pfd [3].events = POLLIN; while (1) { /* Wait for network events. */ rc = poll (pfd, 4, -1); errno_assert (rc >= 0); if (nn_slow (rc < 0 && errno == EINTR)) return -1; nn_assert (rc != 0); /* Process the events. When the event is received, we cease polling for it. */ if (pfd [0].revents & POLLIN) pfd [0].events = 0; if (pfd [1].revents & POLLIN) pfd [1].events = 0; if (pfd [2].revents & POLLIN) pfd [2].events = 0; if (pfd [3].revents & POLLIN) pfd [3].events = 0; /* If possible, pass the message from s1 to s2. */ if (pfd [0].events == 0 && pfd [3].events == 0) { rc = nn_device_mvmsg (device, s1, s2, NN_DONTWAIT); if (nn_slow (rc < 0)) return -1; pfd [0].events = POLLIN; pfd [3].events = POLLIN; } /* If possible, pass the message from s2 to s1. */ if (pfd [2].events == 0 && pfd [1].events == 0) { rc = nn_device_mvmsg (device, s2, s1, NN_DONTWAIT); if (nn_slow (rc < 0)) return -1; pfd [2].events = POLLIN; pfd [1].events = POLLIN; } } } #else #error #endif int nn_device_oneway (struct nn_device_recipe *device, int s1, NN_UNUSED nn_fd s1rcv, int s2, NN_UNUSED nn_fd s2snd) { int rc; while (1) { rc = nn_device_mvmsg (device, s1, s2, 0); if (nn_slow (rc < 0)) return -1; } } int nn_device_mvmsg (struct nn_device_recipe *device, int from, int to, int flags) { int rc; void *body; void *control; struct nn_iovec iov; struct nn_msghdr hdr; iov.iov_base = &body; iov.iov_len = NN_MSG; memset (&hdr, 0, sizeof (hdr)); hdr.msg_iov = &iov; hdr.msg_iovlen = 1; hdr.msg_control = &control; hdr.msg_controllen = NN_MSG; rc = nn_recvmsg (from, &hdr, flags); if (nn_slow (rc < 0 && (nn_errno () == ETERM || nn_errno () == EBADF))) return -1; errno_assert (rc >= 0); rc = device->nn_device_rewritemsg (device, from, to, flags, &hdr, rc); if (nn_slow (rc == -1)) return -1; else if (rc == 0) return 0; nn_assert(rc == 1); rc = nn_sendmsg (to, &hdr, flags); if (nn_slow (rc < 0 && nn_errno () == ETERM)) return -1; errno_assert (rc >= 0); return 0; } int nn_device_rewritemsg (NN_UNUSED struct nn_device_recipe *device, NN_UNUSED int from, NN_UNUSED int to, NN_UNUSED int flags, NN_UNUSED struct nn_msghdr *msghdr, NN_UNUSED int bytes) { return 1; /* always forward */ } nanomsg-0.8-beta/src/devices/device.h0000664000175000017500000001147212623652600020470 0ustar00travistravis00000000000000/* Copyright (c) 2014 Drew Crawford. 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. */ /* Base class for device. */ struct nn_device_recipe { /* NN_CHECK flags. */ int required_checks; /* The entry function. This checks the inputs according to the required_checks flag, chooses the polling function, and starts the device. You can override this function to implement additional checks.*/ int(*nn_device_entry) (struct nn_device_recipe *device, int s1, int s2, int flags); /* The two-way poll function. */ int (*nn_device_twoway) (struct nn_device_recipe *device, int s1, nn_fd s1rcv, nn_fd s1snd, int s2, nn_fd s2rcv, nn_fd s2snd); /* The one-way poll function. */ int (*nn_device_oneway) (struct nn_device_recipe *device, int s1, nn_fd s1rcv, int s2, nn_fd s2snd); int (*nn_device_loopback) (struct nn_device_recipe *device, int s); /* The movemsg function. */ int (*nn_device_mvmsg) (struct nn_device_recipe *device, int from, int to, int flags); /* The message intercept function. This function gives you an opportunity to modify or cancel an nn_msghdr as it passes from one socket to the other. from - the socket that the msghdr was received from to - the socket where it is going flags - the flags that are being used for send and receive functions msghdr - the nn_msghdr that was received from the from socket bytes - the actual received length of the msg. The nn_msghdr->msg_iov->iov_len is not valid because it contains NN_MSG return values: 1 indicates that the msghdr should be forwarded. 0 indicates that the msghdr should *not* be forwarded, e.g. the message is dropped in the device -1 indicates an error. Set errno. */ int (*nn_device_rewritemsg) (struct nn_device_recipe *device, int from, int to, int flags, struct nn_msghdr *msghdr, int bytes); }; /* Default implementations of the functions. */ int nn_device_loopback (struct nn_device_recipe *device, int s); int nn_device_twoway (struct nn_device_recipe *device, int s1, nn_fd s1rcv, nn_fd s1snd, int s2, nn_fd s2rcv, nn_fd s2snd); int nn_device_oneway (struct nn_device_recipe *device, int s1, nn_fd s1rcv, int s2, nn_fd s2snd); int nn_device_mvmsg (struct nn_device_recipe *device, int from, int to, int flags); int nn_device_entry(struct nn_device_recipe *device, int s1, int s2, int flags); int nn_device_rewritemsg(struct nn_device_recipe *device, int from, int to, int flags, struct nn_msghdr *msghdr, int bytes); /* At least one socket must be passed to the device. */ #define NN_CHECK_AT_LEAST_ONE_SOCKET (1 << 0) /* Loopback devices are allowed. */ #define NN_CHECK_ALLOW_LOOPBACK (1 << 1) /* Bidirectional devices are allowed. */ #define NN_CHECK_ALLOW_BIDIRECTIONAL (1 << 2) /* Unidirectional devices are allowed. */ #define NN_CHECK_ALLOW_UNIDIRECTIONAL (1<<3) /* Both sockets must be raw. */ #define NN_CHECK_REQUIRE_RAW_SOCKETS (1 << 4) /* Both sockets must be same protocol family. */ #define NN_CHECK_SAME_PROTOCOL_FAMILY (1 << 5) /* Check socket directionality. */ #define NN_CHECK_SOCKET_DIRECTIONALITY (1 << 6) /* Allows spawning a custom device from a recipe */ int nn_custom_device(struct nn_device_recipe *device, int s1, int s2, int flags); static struct nn_device_recipe nn_ordinary_device = { NN_CHECK_AT_LEAST_ONE_SOCKET | NN_CHECK_ALLOW_LOOPBACK | NN_CHECK_ALLOW_BIDIRECTIONAL | NN_CHECK_REQUIRE_RAW_SOCKETS | NN_CHECK_SAME_PROTOCOL_FAMILY | NN_CHECK_SOCKET_DIRECTIONALITY | NN_CHECK_ALLOW_UNIDIRECTIONAL, nn_device_entry, nn_device_twoway, nn_device_oneway, nn_device_loopback, nn_device_mvmsg, nn_device_rewritemsg }; nanomsg-0.8-beta/src/devices/tcpmuxd.c0000664000175000017500000002721012623652600020705 0ustar00travistravis00000000000000/* Copyright (c) 2014 Martin Sustrik 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 "../nn.h" #if defined NN_HAVE_WINDOWS #include "../utils/err.h" int nn_tcpmuxd (int port) { errno = EPROTONOSUPPORT; return -1; } #else #include "../utils/thread.h" #include "../utils/attr.h" #include "../utils/err.h" #include "../utils/int.h" #include "../utils/cont.h" #include "../utils/wire.h" #include "../utils/alloc.h" #include "../utils/list.h" #include "../utils/mutex.h" #include "../utils/closefd.h" #include #include #include #include #include #include #include #include #include #include #include #include struct nn_tcpmuxd_ctx { int tcp_listener; int ipc_listener; struct nn_list conns; struct pollfd *pfd; size_t pfd_size; size_t pfd_capacity; struct nn_thread thread; }; struct nn_tcpmuxd_conn { int fd; char *service; struct nn_list_item item; }; /* Forward declarations. */ static void nn_tcpmuxd_routine (void *arg); static void nn_tcpmuxd_disconnect (struct nn_tcpmuxd_ctx *ctx, int i); static int nn_tcpmuxd_send_fd (int s, int fd); int nn_tcpmuxd (int port) { int rc; int tcp_listener; int ipc_listener; int opt; struct sockaddr_in tcp_addr; struct sockaddr_un ipc_addr; struct nn_tcpmuxd_ctx *ctx; /* Start listening on the specified TCP port. */ errno = 0; tcp_listener = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); if (tcp_listener < 0) { return -1; } opt = 1; rc = setsockopt (tcp_listener, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof (opt)); if (rc != 0) { return -1; } memset (&tcp_addr, 0, sizeof (tcp_addr)); tcp_addr.sin_family = AF_INET; tcp_addr.sin_port = htons (port); tcp_addr.sin_addr.s_addr = INADDR_ANY; rc = bind (tcp_listener, (struct sockaddr*) &tcp_addr, sizeof (tcp_addr)); if (rc != 0) { return -1; } rc = listen (tcp_listener, 100); if (rc != 0) { return -1; } /* Start listening for incoming IPC connections. */ ipc_addr.sun_family = AF_UNIX; snprintf (ipc_addr.sun_path, sizeof (ipc_addr.sun_path), "/tmp/tcpmux-%d.ipc", (int) port); unlink (ipc_addr.sun_path); errno = 0; ipc_listener = socket (AF_UNIX, SOCK_STREAM, 0); if (ipc_listener < 0) { return -1; } rc = bind (ipc_listener, (struct sockaddr*) &ipc_addr, sizeof (ipc_addr)); if (rc != 0) { return -1; } rc = listen (ipc_listener, 100); if (rc != 0) { return -1; } /* Allocate a context for the daemon. */ ctx = nn_alloc (sizeof (struct nn_tcpmuxd_ctx), "tcpmuxd context"); alloc_assert (ctx); ctx->tcp_listener = tcp_listener; ctx->ipc_listener = ipc_listener; nn_list_init (&ctx->conns); ctx->pfd = nn_alloc (sizeof (struct pollfd) * 16, "tcpmuxd pollfd"); alloc_assert (ctx->pfd); ctx->pfd_capacity = 16; ctx->pfd [0].fd = tcp_listener; ctx->pfd [0].events = POLLIN; ctx->pfd [1].fd = ipc_listener; ctx->pfd [1].events = POLLIN; ctx->pfd_size = 2; /* Run the daemon in a dedicated thread. */ nn_thread_init (&ctx->thread, nn_tcpmuxd_routine, ctx); return 0; } /* Main body of the daemon. */ static void nn_tcpmuxd_routine (void *arg) { int rc; struct nn_tcpmuxd_ctx *ctx; int conn; size_t pos; char service [256]; struct nn_tcpmuxd_conn *tc; size_t sz; ssize_t ssz; int i; struct nn_list_item *it; unsigned char buf [2]; struct timeval tv; ctx = (struct nn_tcpmuxd_ctx*) arg; while (1) { /* Wait for events. */ rc = poll (ctx->pfd, ctx->pfd_size, -1); errno_assert (rc >= 0); nn_assert (rc != 0); /* There's an incoming TCP connection. */ if (ctx->pfd [0].revents & POLLIN) { /* Accept the connection. */ conn = accept (ctx->tcp_listener, NULL, NULL); if (conn < 0 && errno == ECONNABORTED) continue; errno_assert (conn >= 0); /* Set timeouts to prevent malevolent client blocking the service. Note that these options are not supported on Solaris. */ tv.tv_sec = 0; tv.tv_usec = 100000; rc = setsockopt (conn, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof (tv)); errno_assert (rc == 0 || (rc < 0 && errno == ENOPROTOOPT)); rc = setsockopt (conn, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof (tv)); errno_assert (rc == 0 || (rc < 0 && errno == ENOPROTOOPT)); /* Read TCPMUX header. */ pos = 0; while (1) { nn_assert (pos < sizeof (service)); ssz = recv (conn, &service [pos], 1, 0); if (ssz < 0 && errno == EAGAIN) { close (conn); continue; } errno_assert (ssz >= 0); nn_assert (ssz == 1); service [pos] = tolower (service [pos]); if (pos > 0 && service [pos - 1] == 0x0d && service [pos] == 0x0a) break; ++pos; } service [pos - 1] = 0; /* Check whether specified service is listening. */ for (it = nn_list_begin (&ctx->conns); it != nn_list_end (&ctx->conns); it = nn_list_next (&ctx->conns, it)) { tc = nn_cont (it, struct nn_tcpmuxd_conn, item); if (strcmp (service, tc->service) == 0) break; } /* If no one is listening, tear down the connection. */ if (it == nn_list_end (&ctx->conns)) { ssz = send (conn, "-\x0d\x0a", 3, 0); if (ssz < 0 && errno == EAGAIN) { close (conn); continue; } errno_assert (ssz >= 0); nn_assert (ssz == 3); close (conn); continue; } /* Send TCPMUX reply. */ ssz = send (conn, "+\x0d\x0a", 3, 0); if (ssz < 0 && errno == EAGAIN) { close (conn); continue; } errno_assert (ssz >= 0); nn_assert (ssz == 3); /* Pass the file descriptor to the listening process. */ rc = nn_tcpmuxd_send_fd (tc->fd, conn); errno_assert (rc == 0); } /* There's an incoming IPC connection. */ if (ctx->pfd [1].revents & POLLIN) { /* Accept the connection. */ conn = accept (ctx->ipc_listener, NULL, NULL); if (conn < 0 && errno == ECONNABORTED) continue; errno_assert (conn >= 0); /* Create new connection entry. */ tc = nn_alloc (sizeof (struct nn_tcpmuxd_conn), "tcpmuxd_conn"); nn_assert (tc); tc->fd = conn; nn_list_item_init (&tc->item); /* Adjust the pollset. We will poll for errors only. */ ctx->pfd_size++; if (ctx->pfd_size > ctx->pfd_capacity) { ctx->pfd_capacity *= 2; ctx->pfd = nn_realloc (ctx->pfd, sizeof (struct pollfd) * ctx->pfd_capacity); alloc_assert (ctx->pfd); } ctx->pfd [ctx->pfd_size - 1].fd = conn; ctx->pfd [ctx->pfd_size - 1].events = 0; ctx->pfd [ctx->pfd_size - 1].revents = 0; /* Read the connection header. */ ssz = recv (conn, buf, 2, 0); errno_assert (ssz >= 0); nn_assert (ssz == 2); sz = nn_gets (buf); tc->service = nn_alloc (sz + 1, "tcpmuxd_conn.service"); nn_assert (tc->service); ssz = recv (conn, tc->service, sz, 0); errno_assert (ssz >= 0); nn_assert ((size_t)ssz == sz); for (i = 0; (size_t)i != sz; ++i) tc->service [i] = tolower (tc->service [i]); tc->service [sz] = 0; /* Add the entry to the IPC connections list. */ nn_list_insert (&ctx->conns, &tc->item, nn_list_end (&ctx->conns)); } for (i = 2; (size_t)i < ctx->pfd_size; ++i) { if (ctx->pfd [i].revents & POLLERR || ctx->pfd [i].revents & POLLHUP) { nn_tcpmuxd_disconnect (ctx, i); i--; } } } } /* Tear down the IPC connection with index i in the pollset. */ static void nn_tcpmuxd_disconnect (struct nn_tcpmuxd_ctx *ctx, int i) { int fd; struct nn_list_item *it; struct nn_tcpmuxd_conn *conn; fd = ctx->pfd [i].fd; /* Remove the descriptor from the pollset. */ if (ctx->pfd_size > 3) ctx->pfd [i] = ctx->pfd [ctx->pfd_size - 1]; ctx->pfd_size--; /* Remove the connection entry. */ for (it = nn_list_begin (&ctx->conns); it != nn_list_end (&ctx->conns); it = nn_list_next (&ctx->conns, it)) { conn = nn_cont (it, struct nn_tcpmuxd_conn, item); if (conn->fd == fd) { nn_list_erase (&ctx->conns, it); nn_free (conn->service); nn_free (conn); break; } } } /* Send file descriptor fd to IPC socket s. */ static int nn_tcpmuxd_send_fd (int s, int fd) { int rc; struct iovec iov; char c = 0; struct msghdr msg; char control [sizeof (struct cmsghdr) + 10]; #if defined NN_HAVE_MSG_CONTROL struct cmsghdr *cmsg; #endif /* Compose the message. We'll send one byte long dummy message accompanied with the fd.*/ iov.iov_base = &c; iov.iov_len = 1; memset (&msg, 0, sizeof (msg)); msg.msg_iov = &iov; msg.msg_iovlen = 1; /* Attach the file descriptor to the message. */ #if defined NN_HAVE_MSG_CONTROL msg.msg_control = control; msg.msg_controllen = sizeof (control); cmsg = CMSG_FIRSTHDR (&msg); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_len = CMSG_LEN (sizeof (fd)); int *data = (int*) CMSG_DATA (cmsg); *data = fd; msg.msg_controllen = cmsg->cmsg_len; #else msg.msg_accrights = (caddr_t) &fd; msg.msg_accrightslen = sizeof (fd); #endif /* Pass the file descriptor to the registered process. */ rc = sendmsg (s, &msg, 0); if (rc < 0) return -1; nn_assert (rc == 1); /* Sending the file descriptor to other process acts as dup(). Therefore, we have to close the local copy of the file descriptor. */ nn_closefd (fd); return 0; } #endif nanomsg-0.8-beta/src/protocols/0000775000175000017500000000000012623652617017465 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/protocols/bus/0000775000175000017500000000000012623652617020256 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/protocols/bus/bus.h0000664000175000017500000000240112623652600021205 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_BUS_INCLUDED #define NN_BUS_INCLUDED #include "../../protocol.h" extern struct nn_socktype *nn_bus_socktype; #endif nanomsg-0.8-beta/src/protocols/bus/bus.c0000664000175000017500000000756212623652600021215 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "bus.h" #include "xbus.h" #include "../../nn.h" #include "../../bus.h" #include "../../utils/cont.h" #include "../../utils/alloc.h" #include "../../utils/err.h" #include "../../utils/list.h" struct nn_bus { struct nn_xbus xbus; }; /* Private functions. */ static void nn_bus_init (struct nn_bus *self, const struct nn_sockbase_vfptr *vfptr, void *hint); static void nn_bus_term (struct nn_bus *self); /* Implementation of nn_sockbase's virtual functions. */ static void nn_bus_destroy (struct nn_sockbase *self); static int nn_bus_send (struct nn_sockbase *self, struct nn_msg *msg); static int nn_bus_recv (struct nn_sockbase *self, struct nn_msg *msg); static const struct nn_sockbase_vfptr nn_bus_sockbase_vfptr = { NULL, nn_bus_destroy, nn_xbus_add, nn_xbus_rm, nn_xbus_in, nn_xbus_out, nn_xbus_events, nn_bus_send, nn_bus_recv, nn_xbus_setopt, nn_xbus_getopt }; static void nn_bus_init (struct nn_bus *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_xbus_init (&self->xbus, vfptr, hint); } static void nn_bus_term (struct nn_bus *self) { nn_xbus_term (&self->xbus); } static void nn_bus_destroy (struct nn_sockbase *self) { struct nn_bus *bus; bus = nn_cont (self, struct nn_bus, xbus.sockbase); nn_bus_term (bus); nn_free (bus); } static int nn_bus_send (struct nn_sockbase *self, struct nn_msg *msg) { int rc; struct nn_bus *bus; bus = nn_cont (self, struct nn_bus, xbus.sockbase); /* Check for malformed messages. */ if (nn_chunkref_size (&msg->sphdr)) return -EINVAL; /* Send the message. */ rc = nn_xbus_send (&bus->xbus.sockbase, msg); errnum_assert (rc == 0, -rc); return 0; } static int nn_bus_recv (struct nn_sockbase *self, struct nn_msg *msg) { int rc; struct nn_bus *bus; bus = nn_cont (self, struct nn_bus, xbus.sockbase); /* Get next message. */ rc = nn_xbus_recv (&bus->xbus.sockbase, msg); if (nn_slow (rc == -EAGAIN)) return -EAGAIN; errnum_assert (rc == 0, -rc); nn_assert (nn_chunkref_size (&msg->sphdr) == sizeof (uint64_t)); /* Discard the header. */ nn_chunkref_term (&msg->sphdr); nn_chunkref_init (&msg->sphdr, 0); return 0; } static int nn_bus_create (void *hint, struct nn_sockbase **sockbase) { struct nn_bus *self; self = nn_alloc (sizeof (struct nn_bus), "socket (bus)"); alloc_assert (self); nn_bus_init (self, &nn_bus_sockbase_vfptr, hint); *sockbase = &self->xbus.sockbase; return 0; } static struct nn_socktype nn_bus_socktype_struct = { AF_SP, NN_BUS, 0, nn_bus_create, nn_xbus_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_bus_socktype = &nn_bus_socktype_struct; nanomsg-0.8-beta/src/protocols/bus/xbus.h0000664000175000017500000000450512623652600021404 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_XBUS_INCLUDED #define NN_XBUS_INCLUDED #include "../../protocol.h" #include "../utils/dist.h" #include "../utils/fq.h" extern struct nn_socktype *nn_xbus_socktype; struct nn_xbus_data { struct nn_dist_data outitem; struct nn_fq_data initem; }; struct nn_xbus { struct nn_sockbase sockbase; struct nn_dist outpipes; struct nn_fq inpipes; }; void nn_xbus_init (struct nn_xbus *self, const struct nn_sockbase_vfptr *vfptr, void *hint); void nn_xbus_term (struct nn_xbus *self); int nn_xbus_add (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xbus_rm (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xbus_in (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xbus_out (struct nn_sockbase *self, struct nn_pipe *pipe); int nn_xbus_events (struct nn_sockbase *self); int nn_xbus_send (struct nn_sockbase *self, struct nn_msg *msg); int nn_xbus_recv (struct nn_sockbase *self, struct nn_msg *msg); int nn_xbus_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen); int nn_xbus_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen); int nn_xbus_ispeer (int socktype); #endif nanomsg-0.8-beta/src/protocols/bus/xbus.c0000664000175000017500000001515412623652600021401 0ustar00travistravis00000000000000/* Copyright (c) 2013-2014 Martin Sustrik 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 "xbus.h" #include "../../nn.h" #include "../../bus.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/alloc.h" #include "../../utils/list.h" #include "../../utils/int.h" #include "../../utils/attr.h" #include #include /* To make the algorithm super efficient we directly cast pipe pointers to pipe IDs (rather than maintaining a hash table). For this to work, it is neccessary for the pointer to fit in 64-bit ID. */ CT_ASSERT (sizeof (uint64_t) >= sizeof (struct nn_pipe*)); /* Implementation of nn_sockbase's virtual functions. */ static void nn_xbus_destroy (struct nn_sockbase *self); static const struct nn_sockbase_vfptr nn_xbus_sockbase_vfptr = { NULL, nn_xbus_destroy, nn_xbus_add, nn_xbus_rm, nn_xbus_in, nn_xbus_out, nn_xbus_events, nn_xbus_send, nn_xbus_recv, nn_xbus_setopt, nn_xbus_getopt }; void nn_xbus_init (struct nn_xbus *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_sockbase_init (&self->sockbase, vfptr, hint); nn_dist_init (&self->outpipes); nn_fq_init (&self->inpipes); } void nn_xbus_term (struct nn_xbus *self) { nn_fq_term (&self->inpipes); nn_dist_term (&self->outpipes); nn_sockbase_term (&self->sockbase); } static void nn_xbus_destroy (struct nn_sockbase *self) { struct nn_xbus *xbus; xbus = nn_cont (self, struct nn_xbus, sockbase); nn_xbus_term (xbus); nn_free (xbus); } int nn_xbus_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xbus *xbus; struct nn_xbus_data *data; int rcvprio; size_t sz; xbus = nn_cont (self, struct nn_xbus, sockbase); sz = sizeof (rcvprio); nn_pipe_getopt (pipe, NN_SOL_SOCKET, NN_RCVPRIO, &rcvprio, &sz); nn_assert (sz == sizeof (rcvprio)); nn_assert (rcvprio >= 1 && rcvprio <= 16); data = nn_alloc (sizeof (struct nn_xbus_data), "pipe data (xbus)"); alloc_assert (data); nn_fq_add (&xbus->inpipes, &data->initem, pipe, rcvprio); nn_dist_add (&xbus->outpipes, &data->outitem, pipe); nn_pipe_setdata (pipe, data); return 0; } void nn_xbus_rm (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xbus *xbus; struct nn_xbus_data *data; xbus = nn_cont (self, struct nn_xbus, sockbase); data = nn_pipe_getdata (pipe); nn_fq_rm (&xbus->inpipes, &data->initem); nn_dist_rm (&xbus->outpipes, &data->outitem); nn_free (data); } void nn_xbus_in (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xbus *xbus; struct nn_xbus_data *data; xbus = nn_cont (self, struct nn_xbus, sockbase); data = nn_pipe_getdata (pipe); nn_fq_in (&xbus->inpipes, &data->initem); } void nn_xbus_out (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xbus *xbus; struct nn_xbus_data *data; xbus = nn_cont (self, struct nn_xbus, sockbase); data = nn_pipe_getdata (pipe); nn_dist_out (&xbus->outpipes, &data->outitem); } int nn_xbus_events (struct nn_sockbase *self) { return (nn_fq_can_recv (&nn_cont (self, struct nn_xbus, sockbase)->inpipes) ? NN_SOCKBASE_EVENT_IN : 0) | NN_SOCKBASE_EVENT_OUT; } int nn_xbus_send (struct nn_sockbase *self, struct nn_msg *msg) { size_t hdrsz; struct nn_pipe *exclude; hdrsz = nn_chunkref_size (&msg->sphdr); if (hdrsz == 0) exclude = NULL; else if (hdrsz == sizeof (uint64_t)) { memcpy (&exclude, nn_chunkref_data (&msg->sphdr), sizeof (exclude)); nn_chunkref_term (&msg->sphdr); nn_chunkref_init (&msg->sphdr, 0); } else return -EINVAL; return nn_dist_send (&nn_cont (self, struct nn_xbus, sockbase)->outpipes, msg, exclude); } int nn_xbus_recv (struct nn_sockbase *self, struct nn_msg *msg) { int rc; struct nn_xbus *xbus; struct nn_pipe *pipe; xbus = nn_cont (self, struct nn_xbus, sockbase); while (1) { /* Get next message in fair-queued manner. */ rc = nn_fq_recv (&xbus->inpipes, msg, &pipe); if (nn_slow (rc < 0)) return rc; /* The message should have no header. Drop malformed messages. */ if (nn_chunkref_size (&msg->sphdr) == 0) break; nn_msg_term (msg); } /* Add pipe ID to the message header. */ nn_chunkref_term (&msg->sphdr); nn_chunkref_init (&msg->sphdr, sizeof (uint64_t)); memset (nn_chunkref_data (&msg->sphdr), 0, sizeof (uint64_t)); memcpy (nn_chunkref_data (&msg->sphdr), &pipe, sizeof (pipe)); return 0; } int nn_xbus_setopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED const void *optval, NN_UNUSED size_t optvallen) { return -ENOPROTOOPT; } int nn_xbus_getopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED void *optval, NN_UNUSED size_t *optvallen) { return -ENOPROTOOPT; } static int nn_xbus_create (void *hint, struct nn_sockbase **sockbase) { struct nn_xbus *self; self = nn_alloc (sizeof (struct nn_xbus), "socket (bus)"); alloc_assert (self); nn_xbus_init (self, &nn_xbus_sockbase_vfptr, hint); *sockbase = &self->sockbase; return 0; } int nn_xbus_ispeer (int socktype) { return socktype == NN_BUS ? 1 : 0; } static struct nn_socktype nn_xbus_socktype_struct = { AF_SP_RAW, NN_BUS, 0, nn_xbus_create, nn_xbus_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_xbus_socktype = &nn_xbus_socktype_struct; nanomsg-0.8-beta/src/protocols/pair/0000775000175000017500000000000012623652617020420 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/protocols/pair/pair.h0000664000175000017500000000241112623652600021512 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_PAIR_INCLUDED #define NN_PAIR_INCLUDED #include "../../protocol.h" extern struct nn_socktype *nn_pair_socktype; #endif nanomsg-0.8-beta/src/protocols/pair/pair.c0000664000175000017500000000273112623652600021512 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "pair.h" #include "xpair.h" #include "../../nn.h" #include "../../pair.h" #include "../../utils/list.h" static struct nn_socktype nn_pair_socktype_struct = { AF_SP, NN_PAIR, 0, nn_xpair_create, nn_xpair_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_pair_socktype = &nn_pair_socktype_struct; nanomsg-0.8-beta/src/protocols/pair/xpair.h0000664000175000017500000000256212623652600021711 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_XPAIR_INCLUDED #define NN_XPAIR_INCLUDED #include "../../protocol.h" extern struct nn_socktype *nn_xpair_socktype; int nn_xpair_create (void *hint, struct nn_sockbase **sockbase); int nn_xpair_ispeer (int socktype); #endif nanomsg-0.8-beta/src/protocols/pair/xpair.c0000664000175000017500000001314012623652600021676 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "xpair.h" #include "../../nn.h" #include "../../pair.h" #include "../utils/excl.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/alloc.h" #include "../../utils/list.h" #include "../../utils/attr.h" struct nn_xpair { struct nn_sockbase sockbase; struct nn_excl excl; }; /* Private functions. */ static void nn_xpair_init (struct nn_xpair *self, const struct nn_sockbase_vfptr *vfptr, void *hint); static void nn_xpair_term (struct nn_xpair *self); /* Implementation of nn_sockbase's virtual functions. */ static void nn_xpair_destroy (struct nn_sockbase *self); static int nn_xpair_add (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xpair_rm (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xpair_in (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xpair_out (struct nn_sockbase *self, struct nn_pipe *pipe); static int nn_xpair_events (struct nn_sockbase *self); static int nn_xpair_send (struct nn_sockbase *self, struct nn_msg *msg); static int nn_xpair_recv (struct nn_sockbase *self, struct nn_msg *msg); static int nn_xpair_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen); static int nn_xpair_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen); static const struct nn_sockbase_vfptr nn_xpair_sockbase_vfptr = { NULL, nn_xpair_destroy, nn_xpair_add, nn_xpair_rm, nn_xpair_in, nn_xpair_out, nn_xpair_events, nn_xpair_send, nn_xpair_recv, nn_xpair_setopt, nn_xpair_getopt }; static void nn_xpair_init (struct nn_xpair *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_sockbase_init (&self->sockbase, vfptr, hint); nn_excl_init (&self->excl); } static void nn_xpair_term (struct nn_xpair *self) { nn_excl_term (&self->excl); nn_sockbase_term (&self->sockbase); } void nn_xpair_destroy (struct nn_sockbase *self) { struct nn_xpair *xpair; xpair = nn_cont (self, struct nn_xpair, sockbase); nn_xpair_term (xpair); nn_free (xpair); } static int nn_xpair_add (struct nn_sockbase *self, struct nn_pipe *pipe) { return nn_excl_add (&nn_cont (self, struct nn_xpair, sockbase)->excl, pipe); } static void nn_xpair_rm (struct nn_sockbase *self, struct nn_pipe *pipe) { nn_excl_rm (&nn_cont (self, struct nn_xpair, sockbase)->excl, pipe); } static void nn_xpair_in (struct nn_sockbase *self, struct nn_pipe *pipe) { nn_excl_in (&nn_cont (self, struct nn_xpair, sockbase)->excl, pipe); } static void nn_xpair_out (struct nn_sockbase *self, struct nn_pipe *pipe) { nn_excl_out (&nn_cont (self, struct nn_xpair, sockbase)->excl, pipe); } static int nn_xpair_events (struct nn_sockbase *self) { struct nn_xpair *xpair; int events; xpair = nn_cont (self, struct nn_xpair, sockbase); events = 0; if (nn_excl_can_recv (&xpair->excl)) events |= NN_SOCKBASE_EVENT_IN; if (nn_excl_can_send (&xpair->excl)) events |= NN_SOCKBASE_EVENT_OUT; return events; } static int nn_xpair_send (struct nn_sockbase *self, struct nn_msg *msg) { return nn_excl_send (&nn_cont (self, struct nn_xpair, sockbase)->excl, msg); } static int nn_xpair_recv (struct nn_sockbase *self, struct nn_msg *msg) { int rc; rc = nn_excl_recv (&nn_cont (self, struct nn_xpair, sockbase)->excl, msg); /* Discard NN_PIPEBASE_PARSED flag. */ return rc < 0 ? rc : 0; } static int nn_xpair_setopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED const void *optval, NN_UNUSED size_t optvallen) { return -ENOPROTOOPT; } static int nn_xpair_getopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED void *optval, NN_UNUSED size_t *optvallen) { return -ENOPROTOOPT; } int nn_xpair_create (void *hint, struct nn_sockbase **sockbase) { struct nn_xpair *self; self = nn_alloc (sizeof (struct nn_xpair), "socket (pair)"); alloc_assert (self); nn_xpair_init (self, &nn_xpair_sockbase_vfptr, hint); *sockbase = &self->sockbase; return 0; } int nn_xpair_ispeer (int socktype) { return socktype == NN_PAIR ? 1 : 0; } static struct nn_socktype nn_xpair_socktype_struct = { AF_SP_RAW, NN_PAIR, 0, nn_xpair_create, nn_xpair_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_xpair_socktype = &nn_xpair_socktype_struct; nanomsg-0.8-beta/src/protocols/pipeline/0000775000175000017500000000000012623652617021272 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/protocols/pipeline/push.h0000664000175000017500000000241212623652600022411 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_PUSH_INCLUDED #define NN_PUSH_INCLUDED #include "../../protocol.h" extern struct nn_socktype *nn_push_socktype; #endif nanomsg-0.8-beta/src/protocols/pipeline/push.c0000664000175000017500000000276312623652600022415 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "push.h" #include "xpush.h" #include "../../nn.h" #include "../../pipeline.h" #include "../../utils/list.h" static struct nn_socktype nn_push_socktype_struct = { AF_SP, NN_PUSH, NN_SOCKTYPE_FLAG_NORECV, nn_xpush_create, nn_xpush_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_push_socktype = &nn_push_socktype_struct; nanomsg-0.8-beta/src/protocols/pipeline/pull.h0000664000175000017500000000241112623652600022405 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_PULL_INCLUDED #define NN_PULL_INCLUDED #include "../../protocol.h" extern struct nn_socktype *nn_pull_socktype; #endif nanomsg-0.8-beta/src/protocols/pipeline/pull.c0000664000175000017500000000276312623652600022412 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "pull.h" #include "xpull.h" #include "../../nn.h" #include "../../pipeline.h" #include "../../utils/list.h" static struct nn_socktype nn_pull_socktype_struct = { AF_SP, NN_PULL, NN_SOCKTYPE_FLAG_NOSEND, nn_xpull_create, nn_xpull_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_pull_socktype = &nn_pull_socktype_struct; nanomsg-0.8-beta/src/protocols/pipeline/xpull.h0000664000175000017500000000256212623652600022604 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_XPULL_INCLUDED #define NN_XPULL_INCLUDED #include "../../protocol.h" extern struct nn_socktype *nn_xpull_socktype; int nn_xpull_create (void *hint, struct nn_sockbase **sockbase); int nn_xpull_ispeer (int socktype); #endif nanomsg-0.8-beta/src/protocols/pipeline/xpull.c0000664000175000017500000001415512623652600022600 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "xpull.h" #include "../../nn.h" #include "../../pipeline.h" #include "../utils/fq.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/alloc.h" #include "../../utils/list.h" #include "../../utils/attr.h" struct nn_xpull_data { struct nn_fq_data fq; }; struct nn_xpull { struct nn_sockbase sockbase; struct nn_fq fq; }; /* Private functions. */ static void nn_xpull_init (struct nn_xpull *self, const struct nn_sockbase_vfptr *vfptr, void *hint); static void nn_xpull_term (struct nn_xpull *self); /* Implementation of nn_sockbase's virtual functions. */ static void nn_xpull_destroy (struct nn_sockbase *self); static int nn_xpull_add (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xpull_rm (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xpull_in (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xpull_out (struct nn_sockbase *self, struct nn_pipe *pipe); static int nn_xpull_events (struct nn_sockbase *self); static int nn_xpull_recv (struct nn_sockbase *self, struct nn_msg *msg); static int nn_xpull_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen); static int nn_xpull_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen); static const struct nn_sockbase_vfptr nn_xpull_sockbase_vfptr = { NULL, nn_xpull_destroy, nn_xpull_add, nn_xpull_rm, nn_xpull_in, nn_xpull_out, nn_xpull_events, NULL, nn_xpull_recv, nn_xpull_setopt, nn_xpull_getopt }; static void nn_xpull_init (struct nn_xpull *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_sockbase_init (&self->sockbase, vfptr, hint); nn_fq_init (&self->fq); } static void nn_xpull_term (struct nn_xpull *self) { nn_fq_term (&self->fq); nn_sockbase_term (&self->sockbase); } void nn_xpull_destroy (struct nn_sockbase *self) { struct nn_xpull *xpull; xpull = nn_cont (self, struct nn_xpull, sockbase); nn_xpull_term (xpull); nn_free (xpull); } static int nn_xpull_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xpull *xpull; struct nn_xpull_data *data; int rcvprio; size_t sz; xpull = nn_cont (self, struct nn_xpull, sockbase); sz = sizeof (rcvprio); nn_pipe_getopt (pipe, NN_SOL_SOCKET, NN_RCVPRIO, &rcvprio, &sz); nn_assert (sz == sizeof (rcvprio)); nn_assert (rcvprio >= 1 && rcvprio <= 16); data = nn_alloc (sizeof (struct nn_xpull_data), "pipe data (pull)"); alloc_assert (data); nn_pipe_setdata (pipe, data); nn_fq_add (&xpull->fq, &data->fq, pipe, rcvprio); return 0; } static void nn_xpull_rm (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xpull *xpull; struct nn_xpull_data *data; xpull = nn_cont (self, struct nn_xpull, sockbase); data = nn_pipe_getdata (pipe); nn_fq_rm (&xpull->fq, &data->fq); nn_free (data); } static void nn_xpull_in (NN_UNUSED struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xpull *xpull; struct nn_xpull_data *data; xpull = nn_cont (self, struct nn_xpull, sockbase); data = nn_pipe_getdata (pipe); nn_fq_in (&xpull->fq, &data->fq); } static void nn_xpull_out (NN_UNUSED struct nn_sockbase *self, NN_UNUSED struct nn_pipe *pipe) { /* We are not going to send any messages, so there's no point is maintaining a list of pipes ready for sending. */ } static int nn_xpull_events (struct nn_sockbase *self) { return nn_fq_can_recv (&nn_cont (self, struct nn_xpull, sockbase)->fq) ? NN_SOCKBASE_EVENT_IN : 0; } static int nn_xpull_recv (struct nn_sockbase *self, struct nn_msg *msg) { int rc; rc = nn_fq_recv (&nn_cont (self, struct nn_xpull, sockbase)->fq, msg, NULL); /* Discard NN_PIPEBASE_PARSED flag. */ return rc < 0 ? rc : 0; } static int nn_xpull_setopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED const void *optval, NN_UNUSED size_t optvallen) { return -ENOPROTOOPT; } static int nn_xpull_getopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED void *optval, NN_UNUSED size_t *optvallen) { return -ENOPROTOOPT; } int nn_xpull_create (void *hint, struct nn_sockbase **sockbase) { struct nn_xpull *self; self = nn_alloc (sizeof (struct nn_xpull), "socket (pull)"); alloc_assert (self); nn_xpull_init (self, &nn_xpull_sockbase_vfptr, hint); *sockbase = &self->sockbase; return 0; } int nn_xpull_ispeer (int socktype) { return socktype == NN_PUSH ? 1 : 0; } static struct nn_socktype nn_xpull_socktype_struct = { AF_SP_RAW, NN_PULL, NN_SOCKTYPE_FLAG_NOSEND, nn_xpull_create, nn_xpull_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_xpull_socktype = &nn_xpull_socktype_struct; nanomsg-0.8-beta/src/protocols/pipeline/xpush.h0000664000175000017500000000256312623652600022610 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_XPUSH_INCLUDED #define NN_XPUSH_INCLUDED #include "../../protocol.h" extern struct nn_socktype *nn_xpush_socktype; int nn_xpush_create (void *hint, struct nn_sockbase **sockbase); int nn_xpush_ispeer (int socktype); #endif nanomsg-0.8-beta/src/protocols/pipeline/xpush.c0000664000175000017500000001416512623652600022604 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "xpush.h" #include "../../nn.h" #include "../../pipeline.h" #include "../utils/lb.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/alloc.h" #include "../../utils/list.h" #include "../../utils/attr.h" struct nn_xpush_data { struct nn_lb_data lb; }; struct nn_xpush { struct nn_sockbase sockbase; struct nn_lb lb; }; /* Private functions. */ static void nn_xpush_init (struct nn_xpush *self, const struct nn_sockbase_vfptr *vfptr, void *hint); static void nn_xpush_term (struct nn_xpush *self); /* Implementation of nn_sockbase's virtual functions. */ static void nn_xpush_destroy (struct nn_sockbase *self); static int nn_xpush_add (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xpush_rm (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xpush_in (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xpush_out (struct nn_sockbase *self, struct nn_pipe *pipe); static int nn_xpush_events (struct nn_sockbase *self); static int nn_xpush_send (struct nn_sockbase *self, struct nn_msg *msg); static int nn_xpush_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen); static int nn_xpush_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen); static const struct nn_sockbase_vfptr nn_xpush_sockbase_vfptr = { NULL, nn_xpush_destroy, nn_xpush_add, nn_xpush_rm, nn_xpush_in, nn_xpush_out, nn_xpush_events, nn_xpush_send, NULL, nn_xpush_setopt, nn_xpush_getopt }; static void nn_xpush_init (struct nn_xpush *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_sockbase_init (&self->sockbase, vfptr, hint); nn_lb_init (&self->lb); } static void nn_xpush_term (struct nn_xpush *self) { nn_lb_term (&self->lb); nn_sockbase_term (&self->sockbase); } void nn_xpush_destroy (struct nn_sockbase *self) { struct nn_xpush *xpush; xpush = nn_cont (self, struct nn_xpush, sockbase); nn_xpush_term (xpush); nn_free (xpush); } static int nn_xpush_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xpush *xpush; struct nn_xpush_data *data; int sndprio; size_t sz; xpush = nn_cont (self, struct nn_xpush, sockbase); sz = sizeof (sndprio); nn_pipe_getopt (pipe, NN_SOL_SOCKET, NN_SNDPRIO, &sndprio, &sz); nn_assert (sz == sizeof (sndprio)); nn_assert (sndprio >= 1 && sndprio <= 16); data = nn_alloc (sizeof (struct nn_xpush_data), "pipe data (push)"); alloc_assert (data); nn_pipe_setdata (pipe, data); nn_lb_add (&xpush->lb, &data->lb, pipe, sndprio); return 0; } static void nn_xpush_rm (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xpush *xpush; struct nn_xpush_data *data; xpush = nn_cont (self, struct nn_xpush, sockbase); data = nn_pipe_getdata (pipe); nn_lb_rm (&xpush->lb, &data->lb); nn_free (data); nn_sockbase_stat_increment (self, NN_STAT_CURRENT_SND_PRIORITY, nn_lb_get_priority (&xpush->lb)); } static void nn_xpush_in (NN_UNUSED struct nn_sockbase *self, NN_UNUSED struct nn_pipe *pipe) { /* We are not going to receive any messages, so there's no need to store the list of inbound pipes. */ } static void nn_xpush_out (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xpush *xpush; struct nn_xpush_data *data; xpush = nn_cont (self, struct nn_xpush, sockbase); data = nn_pipe_getdata (pipe); nn_lb_out (&xpush->lb, &data->lb); nn_sockbase_stat_increment (self, NN_STAT_CURRENT_SND_PRIORITY, nn_lb_get_priority (&xpush->lb)); } static int nn_xpush_events (struct nn_sockbase *self) { return nn_lb_can_send (&nn_cont (self, struct nn_xpush, sockbase)->lb) ? NN_SOCKBASE_EVENT_OUT : 0; } static int nn_xpush_send (struct nn_sockbase *self, struct nn_msg *msg) { return nn_lb_send (&nn_cont (self, struct nn_xpush, sockbase)->lb, msg, NULL); } static int nn_xpush_setopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED const void *optval, NN_UNUSED size_t optvallen) { return -ENOPROTOOPT; } static int nn_xpush_getopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED void *optval, NN_UNUSED size_t *optvallen) { return -ENOPROTOOPT; } int nn_xpush_create (void *hint, struct nn_sockbase **sockbase) { struct nn_xpush *self; self = nn_alloc (sizeof (struct nn_xpush), "socket (push)"); alloc_assert (self); nn_xpush_init (self, &nn_xpush_sockbase_vfptr, hint); *sockbase = &self->sockbase; return 0; } int nn_xpush_ispeer (int socktype) { return socktype == NN_PULL ? 1 : 0; } static struct nn_socktype nn_xpush_socktype_struct = { AF_SP_RAW, NN_PUSH, NN_SOCKTYPE_FLAG_NORECV, nn_xpush_create, nn_xpush_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_xpush_socktype = &nn_xpush_socktype_struct; nanomsg-0.8-beta/src/protocols/pubsub/0000775000175000017500000000000012623652617020765 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/protocols/pubsub/pub.h0000664000175000017500000000240112623652600021711 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_PUB_INCLUDED #define NN_PUB_INCLUDED #include "../../protocol.h" extern struct nn_socktype *nn_pub_socktype; #endif nanomsg-0.8-beta/src/protocols/pubsub/pub.c0000664000175000017500000000274412623652600021716 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "pub.h" #include "xpub.h" #include "../../nn.h" #include "../../pubsub.h" #include "../../utils/list.h" static struct nn_socktype nn_pub_socktype_struct = { AF_SP, NN_PUB, NN_SOCKTYPE_FLAG_NORECV, nn_xpub_create, nn_xpub_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_pub_socktype = &nn_pub_socktype_struct; nanomsg-0.8-beta/src/protocols/pubsub/sub.h0000664000175000017500000000240112623652600021714 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_SUB_INCLUDED #define NN_SUB_INCLUDED #include "../../protocol.h" extern struct nn_socktype *nn_sub_socktype; #endif nanomsg-0.8-beta/src/protocols/pubsub/sub.c0000664000175000017500000000274412623652600021721 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "sub.h" #include "xsub.h" #include "../../nn.h" #include "../../pubsub.h" #include "../../utils/list.h" static struct nn_socktype nn_sub_socktype_struct = { AF_SP, NN_SUB, NN_SOCKTYPE_FLAG_NOSEND, nn_xsub_create, nn_xsub_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_sub_socktype = &nn_sub_socktype_struct; nanomsg-0.8-beta/src/protocols/pubsub/trie.h0000664000175000017500000001105412623652600022072 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_TRIE_INCLUDED #define NN_TRIE_INCLUDED #include "../../utils/int.h" #include /* This class implements highly memory-efficient patricia trie. */ /* Maximum length of the prefix. */ #define NN_TRIE_PREFIX_MAX 10 /* Maximum number of children in the sparse mode. */ #define NN_TRIE_SPARSE_MAX 8 /* 'type' is set to this value when in the dense mode. */ #define NN_TRIE_DENSE_TYPE (NN_TRIE_SPARSE_MAX + 1) /* This structure represents a node in patricia trie. It's a header to be followed by the array of pointers to child nodes. Each node represents the string composed of all the prefixes on the way from the trie root, including the prefix in that node. */ struct nn_trie_node { /* Number of subscriptions to the given string. */ uint32_t refcount; /* Number of elements is a sparse array, or NN_TRIE_DENSE_TYPE in case the array of children is dense. */ uint8_t type; /* The node adds more characters to the string, compared to the parent node. If there is only a single character added, it's represented directly in the child array. If there's more than one character added, all but the last one are stored as a 'prefix'. */ uint8_t prefix_len; uint8_t prefix [NN_TRIE_PREFIX_MAX]; /* The array of characters pointing to individual children of the node. Actual pointers to child nodes are stored in the memory following nn_trie_node structure. */ union { /* Sparse array means that individual children are identified by characters stored in 'children' array. The number of characters in the array is specified in the 'type' field. */ struct { uint8_t children [NN_TRIE_SPARSE_MAX]; } sparse; /* Dense array means that the array of node pointers following the structure corresponds to a continuous list of characters starting by 'min' character and ending by 'max' character. The characters in the range that have no corresponding child node are represented by NULL pointers. 'nbr' is the count of child nodes. */ struct { uint8_t min; uint8_t max; uint16_t nbr; /* There are 4 bytes of padding here. */ } dense; } u; }; /* The structure is followed by the array of pointers to children. */ struct nn_trie { /* The root node of the trie (representing the empty subscription). */ struct nn_trie_node *root; }; /* Initialise an empty trie. */ void nn_trie_init (struct nn_trie *self); /* Release all the resources associated with the trie. */ void nn_trie_term (struct nn_trie *self); /* Add the string to the trie. If the string is not yet there, 1 is returned. If it already exists in the trie, its reference count is incremented and 0 is returned. */ int nn_trie_subscribe (struct nn_trie *self, const uint8_t *data, size_t size); /* Remove the string from the trie. If the string was actually removed, 1 is returned. If reference count was decremented without falling to zero, 0 is returned. */ int nn_trie_unsubscribe (struct nn_trie *self, const uint8_t *data, size_t size); /* Checks the supplied string. If it matches it returns 1, if it does not it returns 0. */ int nn_trie_match (struct nn_trie *self, const uint8_t *data, size_t size); /* Debugging interface. */ void nn_trie_dump (struct nn_trie *self); #endif nanomsg-0.8-beta/src/protocols/pubsub/trie.c0000664000175000017500000005113412623652600022070 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 #include #include #include "trie.h" #include "../../utils/alloc.h" #include "../../utils/fast.h" #include "../../utils/err.h" /* Double check that the size of node structure is as small as we believe it to be. */ CT_ASSERT (sizeof (struct nn_trie_node) == 24); /* Forward declarations. */ static struct nn_trie_node *nn_node_compact (struct nn_trie_node *self); static int nn_node_check_prefix (struct nn_trie_node *self, const uint8_t *data, size_t size); static struct nn_trie_node **nn_node_child (struct nn_trie_node *self, int index); static struct nn_trie_node **nn_node_next (struct nn_trie_node *self, uint8_t c); static int nn_node_unsubscribe (struct nn_trie_node **self, const uint8_t *data, size_t size); static void nn_node_term (struct nn_trie_node *self); static int nn_node_has_subscribers (struct nn_trie_node *self); static void nn_node_dump (struct nn_trie_node *self, int indent); static void nn_node_indent (int indent); static void nn_node_putchar (uint8_t c); void nn_trie_init (struct nn_trie *self) { self->root = NULL; } void nn_trie_term (struct nn_trie *self) { nn_node_term (self->root); } void nn_trie_dump (struct nn_trie *self) { nn_node_dump (self->root, 0); } void nn_node_dump (struct nn_trie_node *self, int indent) { int i; int children; if (!self) { nn_node_indent (indent); printf ("NULL\n"); return; } nn_node_indent (indent); printf ("===================\n"); nn_node_indent (indent); printf ("refcount=%d\n", (int) self->refcount); nn_node_indent (indent); printf ("prefix_len=%d\n", (int) self->prefix_len); nn_node_indent (indent); if (self->type == NN_TRIE_DENSE_TYPE) printf ("type=dense\n"); else printf ("type=sparse\n"); nn_node_indent (indent); printf ("prefix=\""); for (i = 0; i != self->prefix_len; ++i) nn_node_putchar (self->prefix [i]); printf ("\"\n"); if (self->type <= 8) { nn_node_indent (indent); printf ("sparse.children=\""); for (i = 0; i != self->type; ++i) nn_node_putchar (self->u.sparse.children [i]); printf ("\"\n"); children = self->type; } else { nn_node_indent (indent); printf ("dense.min='%c' (%d)\n", (char) self->u.dense.min, (int) self->u.dense.min); nn_node_indent (indent); printf ("dense.max='%c' (%d)\n", (char) self->u.dense.max, (int) self->u.dense.max); nn_node_indent (indent); printf ("dense.nbr=%d\n", (int) self->u.dense.nbr); children = self->u.dense.max - self->u.dense.min + 1; } for (i = 0; i != children; ++i) nn_node_dump (((struct nn_trie_node**) (self + 1)) [i], indent + 1); nn_node_indent (indent); printf ("===================\n"); } void nn_node_indent (int indent) { int i; for (i = 0; i != indent * 4; ++i) nn_node_putchar (' '); } void nn_node_putchar (uint8_t c) { if (c < 32 || c > 127) putchar ('?'); else putchar (c); } void nn_node_term (struct nn_trie_node *self) { int children; int i; /* Trivial case of the recursive algorithm. */ if (!self) return; /* Recursively destroy the child nodes. */ children = self->type <= NN_TRIE_SPARSE_MAX ? self->type : (self->u.dense.max - self->u.dense.min + 1); for (i = 0; i != children; ++i) nn_node_term (*nn_node_child (self, i)); /* Deallocate this node. */ nn_free (self); } int nn_node_check_prefix (struct nn_trie_node *self, const uint8_t *data, size_t size) { /* Check how many characters from the data match the prefix. */ int i; for (i = 0; i != self->prefix_len; ++i) { if (!size || self->prefix [i] != *data) return i; ++data; --size; } return self->prefix_len; } struct nn_trie_node **nn_node_child (struct nn_trie_node *self, int index) { /* Finds pointer to the n-th child of the node. */ return ((struct nn_trie_node**) (self + 1)) + index; } struct nn_trie_node **nn_node_next (struct nn_trie_node *self, uint8_t c) { /* Finds the pointer to the next node based on the supplied character. If there is no such pointer, it returns NULL. */ int i; if (self->type == 0) return NULL; /* Sparse mode. */ if (self->type <= 8) { for (i = 0; i != self->type; ++i) if (self->u.sparse.children [i] == c) return nn_node_child (self, i); return NULL; } /* Dense mode. */ if (c < self->u.dense.min || c > self->u.dense.max) return NULL; return nn_node_child (self, c - self->u.dense.min); } struct nn_trie_node *nn_node_compact (struct nn_trie_node *self) { /* Tries to merge the node with the child node. Returns pointer to the compacted node. */ struct nn_trie_node *ch; /* Node that is a subscription cannot be compacted. */ if (nn_node_has_subscribers (self)) return self; /* Only a node with a single child can be compacted. */ if (self->type != 1) return self; /* Check whether combined prefixes would fix into a single node. */ ch = *nn_node_child (self, 0); if (self->prefix_len + ch->prefix_len + 1 > NN_TRIE_PREFIX_MAX) return self; /* Concatenate the prefixes. */ memmove (ch->prefix + self->prefix_len + 1, ch->prefix, ch->prefix_len); memcpy (ch->prefix, self->prefix, self->prefix_len); ch->prefix [self->prefix_len] = self->u.sparse.children [0]; ch->prefix_len += self->prefix_len + 1; /* Get rid of the obsolete parent node. */ nn_free (self); /* Return the new compacted node. */ return ch; } int nn_trie_subscribe (struct nn_trie *self, const uint8_t *data, size_t size) { int i; struct nn_trie_node **node; struct nn_trie_node **n; struct nn_trie_node *ch; struct nn_trie_node *old_node; int pos; uint8_t c; uint8_t c2; uint8_t new_min; uint8_t new_max; int old_children; int new_children; int inserted; int more_nodes; /* Step 1 -- Traverse the trie. */ node = &self->root; pos = 0; while (1) { /* If there are no more nodes on the path, go to step 4. */ if (!*node) goto step4; /* Check whether prefix matches the new subscription. */ pos = nn_node_check_prefix (*node, data, size); data += pos; size -= pos; /* If only part of the prefix matches, go to step 2. */ if (pos < (*node)->prefix_len) goto step2; /* Even if whole prefix matches and there's no more data to match, go directly to step 5. */ if (!size) goto step5; /* Move to the next node. If it is not present, go to step 3. */ n = nn_node_next (*node, *data); if (!n || !*n) goto step3; node = n; ++data; --size; } /* Step 2 -- Split the prefix into two parts if required. */ step2: ch = *node; *node = nn_alloc (sizeof (struct nn_trie_node) + sizeof (struct nn_trie_node*), "trie node"); assert (*node); (*node)->refcount = 0; (*node)->prefix_len = pos; (*node)->type = 1; memcpy ((*node)->prefix, ch->prefix, pos); (*node)->u.sparse.children [0] = ch->prefix [pos]; ch->prefix_len -= (pos + 1); memmove (ch->prefix, ch->prefix + pos + 1, ch->prefix_len); ch = nn_node_compact (ch); *nn_node_child (*node, 0) = ch; pos = (*node)->prefix_len; /* Step 3 -- Adjust the child array to accommodate the new character. */ step3: /* If there are no more data in the subscription, there's nothing to adjust in the child array. Proceed directly to the step 5. */ if (!size) goto step5; /* If the new branch fits into sparse array... */ if ((*node)->type < NN_TRIE_SPARSE_MAX) { *node = nn_realloc (*node, sizeof (struct nn_trie_node) + ((*node)->type + 1) * sizeof (struct nn_trie_node*)); assert (*node); (*node)->u.sparse.children [(*node)->type] = *data; ++(*node)->type; node = nn_node_child (*node, (*node)->type - 1); *node = NULL; ++data; --size; goto step4; } /* If the node is already a dense array, resize it to fit the next character. */ if ((*node)->type == NN_TRIE_DENSE_TYPE) { c = *data; if (c < (*node)->u.dense.min || c > (*node)->u.dense.max) { new_min = (*node)->u.dense.min < c ? (*node)->u.dense.min : c; new_max = (*node)->u.dense.max > c ? (*node)->u.dense.max : c; *node = nn_realloc (*node, sizeof (struct nn_trie_node) + (new_max - new_min + 1) * sizeof (struct nn_trie_node*)); assert (*node); old_children = (*node)->u.dense.max - (*node)->u.dense.min + 1; new_children = new_max - new_min + 1; if ((*node)->u.dense.min != new_min) { inserted = (*node)->u.dense.min - new_min; memmove (nn_node_child (*node, inserted), nn_node_child (*node, 0), old_children * sizeof (struct nn_trie_node*)); memset (nn_node_child (*node, 0), 0, inserted * sizeof (struct nn_trie_node*)); } else { memset (nn_node_child (*node, old_children), 0, (new_children - old_children) * sizeof (struct nn_trie_node*)); } (*node)->u.dense.min = new_min; (*node)->u.dense.max = new_max; } ++(*node)->u.dense.nbr; node = nn_node_child (*node, c - (*node)->u.dense.min); ++data; --size; goto step4; } /* This is a sparse array, but no more children can be added to it. We have to convert it into a dense array. */ { /* First, determine the range of children. */ new_min = 255; new_max = 0; for (i = 0; i != (*node)->type; ++i) { c2 = (*node)->u.sparse.children [i]; new_min = new_min < c2 ? new_min : c2; new_max = new_max > c2 ? new_max : c2; } new_min = new_min < *data ? new_min : *data; new_max = new_max > *data ? new_max : *data; /* Create a new mode, while keeping the old one for a while. */ old_node = *node; *node = (struct nn_trie_node*) nn_alloc (sizeof (struct nn_trie_node) + (new_max - new_min + 1) * sizeof (struct nn_trie_node*), "trie node"); assert (*node); /* Fill in the new node. */ (*node)->refcount = 0; (*node)->prefix_len = old_node->prefix_len; (*node)->type = NN_TRIE_DENSE_TYPE; memcpy ((*node)->prefix, old_node->prefix, old_node->prefix_len); (*node)->u.dense.min = new_min; (*node)->u.dense.max = new_max; (*node)->u.dense.nbr = old_node->type + 1; memset (*node + 1, 0, (new_max - new_min + 1) * sizeof (struct nn_trie_node*)); for (i = 0; i != old_node->type; ++i) *nn_node_child (*node, old_node->u.sparse.children [i] - new_min) = *nn_node_child (old_node, i); node = nn_node_next (*node, *data); ++data; --size; /* Get rid of the obsolete old node. */ nn_free (old_node); } /* Step 4 -- Create new nodes for remaining part of the subscription. */ step4: assert (!*node); while (1) { /* Create a new node to hold the next part of the subscription. */ more_nodes = size > NN_TRIE_PREFIX_MAX; *node = nn_alloc (sizeof (struct nn_trie_node) + (more_nodes ? sizeof (struct nn_trie_node*) : 0), "trie node"); assert (*node); /* Fill in the new node. */ (*node)->refcount = 0; (*node)->type = more_nodes ? 1 : 0; (*node)->prefix_len = size < (uint8_t) NN_TRIE_PREFIX_MAX ? (uint8_t) size : (uint8_t) NN_TRIE_PREFIX_MAX; memcpy ((*node)->prefix, data, (*node)->prefix_len); data += (*node)->prefix_len; size -= (*node)->prefix_len; if (!more_nodes) break; (*node)->u.sparse.children [0] = *data; node = nn_node_child (*node, 0); ++data; --size; } /* Step 5 -- Create the subscription as such. */ step5: ++(*node)->refcount; /* Return 1 in case of a fresh subscription. */ return (*node)->refcount == 1 ? 1 : 0; } int nn_trie_match (struct nn_trie *self, const uint8_t *data, size_t size) { struct nn_trie_node *node; struct nn_trie_node **tmp; node = self->root; while (1) { /* If we are at the end of the trie, return. */ if (!node) return 0; /* Check whether whole prefix matches the data. If not so, the whole string won't match. */ if (nn_node_check_prefix (node, data, size) != node->prefix_len) return 0; /* Skip the prefix. */ data += node->prefix_len; size -= node->prefix_len; /* If all the data are matched, return. */ if (nn_node_has_subscribers (node)) return 1; /* Move to the next node. */ tmp = nn_node_next (node, *data); node = tmp ? *tmp : NULL; ++data; --size; } } int nn_trie_unsubscribe (struct nn_trie *self, const uint8_t *data, size_t size) { return nn_node_unsubscribe (&self->root, data, size); } static int nn_node_unsubscribe (struct nn_trie_node **self, const uint8_t *data, size_t size) { int i; int j; int index; int new_min; struct nn_trie_node **ch; struct nn_trie_node *new_node; struct nn_trie_node *ch2; if (!size) goto found; /* If prefix does not match the data, return. */ if (nn_node_check_prefix (*self, data, size) != (*self)->prefix_len) return 0; /* Skip the prefix. */ data += (*self)->prefix_len; size -= (*self)->prefix_len; if (!size) goto found; /* Move to the next node. */ ch = nn_node_next (*self, *data); if (!ch) return 0; /* TODO: This should be an error. */ /* Recursive traversal of the trie happens here. If the subscription wasn't really removed, nothing have changed in the trie and no additional pruning is needed. */ if (nn_node_unsubscribe (ch, data + 1, size - 1) == 0) return 0; /* Subscription removal is already done. Now we are going to compact the trie. However, if the following node remains in place, there's nothing to compact here. */ if (*ch) return 1; /* Sparse array. */ if ((*self)->type < NN_TRIE_DENSE_TYPE) { /* Get the indices of the removed child. */ for (index = 0; index != (*self)->type; ++index) if ((*self)->u.sparse.children [index] == *data) break; assert (index != (*self)->type); /* Remove the destroyed child from both lists of children. */ memmove ( (*self)->u.sparse.children + index, (*self)->u.sparse.children + index + 1, (*self)->type - index - 1); memmove ( nn_node_child (*self, index), nn_node_child (*self, index + 1), ((*self)->type - index - 1) * sizeof (struct nn_trie_node*)); --(*self)->type; *self = nn_realloc (*self, sizeof (struct nn_trie_node) + ((*self)->type * sizeof (struct nn_trie_node*))); assert (*self); /* If there are no more children and no refcount, we can delete the node altogether. */ if (!(*self)->type && !nn_node_has_subscribers (*self)) { nn_free (*self); *self = NULL; return 1; } /* Try to merge the node with the following node. */ *self = nn_node_compact (*self); return 1; } /* Dense array. */ /* In this case the array stays dense. We have to adjust the limits of the array, if appropriate. */ if ((*self)->u.dense.nbr > NN_TRIE_SPARSE_MAX + 1) { /* If the removed item is the leftmost one, trim the array from the left side. */ if (*data == (*self)->u.dense.min) { for (i = 0; i != (*self)->u.dense.max - (*self)->u.dense.min + 1; ++i) if (*nn_node_child (*self, i)) break; new_min = i + (*self)->u.dense.min; memmove (nn_node_child (*self, 0), nn_node_child (*self, i), ((*self)->u.dense.max - new_min + 1) * sizeof (struct nn_trie_node*)); (*self)->u.dense.min = new_min; --(*self)->u.dense.nbr; *self = nn_realloc (*self, sizeof (struct nn_trie_node) + ((*self)->u.dense.max - new_min + 1) * sizeof (struct nn_trie_node*)); assert (*self); return 1; } /* If the removed item is the rightmost one, trim the array from the right side. */ if (*data == (*self)->u.dense.max) { for (i = (*self)->u.dense.max - (*self)->u.dense.min; i != 0; --i) if (*nn_node_child (*self, i)) break; (*self)->u.dense.max = i + (*self)->u.dense.min; --(*self)->u.dense.nbr; *self = nn_realloc (*self, sizeof (struct nn_trie_node) + ((*self)->u.dense.max - (*self)->u.dense.min + 1) * sizeof (struct nn_trie_node*)); assert (*self); return 1; } /* If the item is removed from the middle of the array, do nothing. */ --(*self)->u.dense.nbr; return 1; } /* Convert dense array into sparse array. */ { new_node = nn_alloc (sizeof (struct nn_trie_node) + NN_TRIE_SPARSE_MAX * sizeof (struct nn_trie_node*), "trie node"); assert (new_node); new_node->refcount = 0; new_node->prefix_len = (*self)->prefix_len; memcpy (new_node->prefix, (*self)->prefix, new_node->prefix_len); new_node->type = NN_TRIE_SPARSE_MAX; j = 0; for (i = 0; i != (*self)->u.dense.max - (*self)->u.dense.min + 1; ++i) { ch2 = *nn_node_child (*self, i); if (ch2) { new_node->u.sparse.children [j] = i + (*self)->u.dense.min; *nn_node_child (new_node, j) = ch2; ++j; } } assert (j == NN_TRIE_SPARSE_MAX); nn_free (*self); *self = new_node; return 1; } found: /* We are at the end of the subscription here. */ /* Subscription doesn't exist. */ if (nn_slow (!*self || !nn_node_has_subscribers (*self))) return -EINVAL; /* Subscription exists. Unsubscribe. */ --(*self)->refcount; /* If reference count has dropped to zero we can try to compact the node. */ if (!(*self)->refcount) { /* If there are no children, we can delete the node altogether. */ if (!(*self)->type) { nn_free (*self); *self = NULL; return 1; } /* Try to merge the node with the following node. */ *self = nn_node_compact (*self); return 1; } return 0; } int nn_node_has_subscribers (struct nn_trie_node *node) { /* Returns 1 when there are no subscribers associated with the node. */ return node->refcount ? 1 : 0; } nanomsg-0.8-beta/src/protocols/pubsub/xpub.h0000664000175000017500000000255612623652600022114 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_XPUB_INCLUDED #define NN_XPUB_INCLUDED #include "../../protocol.h" extern struct nn_socktype *nn_xpub_socktype; int nn_xpub_create (void *hint, struct nn_sockbase **sockbase); int nn_xpub_ispeer (int socktype); #endif nanomsg-0.8-beta/src/protocols/pubsub/xpub.c0000664000175000017500000001325712623652600022107 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "xpub.h" #include "../../nn.h" #include "../../pubsub.h" #include "../utils/dist.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/alloc.h" #include "../../utils/list.h" #include "../../utils/attr.h" #include struct nn_xpub_data { struct nn_dist_data item; }; struct nn_xpub { /* The generic socket base class. */ struct nn_sockbase sockbase; /* Distributor. */ struct nn_dist outpipes; }; /* Private functions. */ static void nn_xpub_init (struct nn_xpub *self, const struct nn_sockbase_vfptr *vfptr, void *hint); static void nn_xpub_term (struct nn_xpub *self); /* Implementation of nn_sockbase's virtual functions. */ static void nn_xpub_destroy (struct nn_sockbase *self); static int nn_xpub_add (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xpub_rm (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xpub_in (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xpub_out (struct nn_sockbase *self, struct nn_pipe *pipe); static int nn_xpub_events (struct nn_sockbase *self); static int nn_xpub_send (struct nn_sockbase *self, struct nn_msg *msg); static int nn_xpub_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen); static int nn_xpub_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen); static const struct nn_sockbase_vfptr nn_xpub_sockbase_vfptr = { NULL, nn_xpub_destroy, nn_xpub_add, nn_xpub_rm, nn_xpub_in, nn_xpub_out, nn_xpub_events, nn_xpub_send, NULL, nn_xpub_setopt, nn_xpub_getopt }; static void nn_xpub_init (struct nn_xpub *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_sockbase_init (&self->sockbase, vfptr, hint); nn_dist_init (&self->outpipes); } static void nn_xpub_term (struct nn_xpub *self) { nn_dist_term (&self->outpipes); nn_sockbase_term (&self->sockbase); } void nn_xpub_destroy (struct nn_sockbase *self) { struct nn_xpub *xpub; xpub = nn_cont (self, struct nn_xpub, sockbase); nn_xpub_term (xpub); nn_free (xpub); } static int nn_xpub_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xpub *xpub; struct nn_xpub_data *data; xpub = nn_cont (self, struct nn_xpub, sockbase); data = nn_alloc (sizeof (struct nn_xpub_data), "pipe data (pub)"); alloc_assert (data); nn_dist_add (&xpub->outpipes, &data->item, pipe); nn_pipe_setdata (pipe, data); return 0; } static void nn_xpub_rm (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xpub *xpub; struct nn_xpub_data *data; xpub = nn_cont (self, struct nn_xpub, sockbase); data = nn_pipe_getdata (pipe); nn_dist_rm (&xpub->outpipes, &data->item); nn_free (data); } static void nn_xpub_in (NN_UNUSED struct nn_sockbase *self, NN_UNUSED struct nn_pipe *pipe) { /* We shouldn't get any messages from subscribers. */ nn_assert (0); } static void nn_xpub_out (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xpub *xpub; struct nn_xpub_data *data; xpub = nn_cont (self, struct nn_xpub, sockbase); data = nn_pipe_getdata (pipe); nn_dist_out (&xpub->outpipes, &data->item); } static int nn_xpub_events (NN_UNUSED struct nn_sockbase *self) { return NN_SOCKBASE_EVENT_OUT; } static int nn_xpub_send (struct nn_sockbase *self, struct nn_msg *msg) { return nn_dist_send (&nn_cont (self, struct nn_xpub, sockbase)->outpipes, msg, NULL); } static int nn_xpub_setopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED const void *optval, NN_UNUSED size_t optvallen) { return -ENOPROTOOPT; } static int nn_xpub_getopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED void *optval, NN_UNUSED size_t *optvallen) { return -ENOPROTOOPT; } int nn_xpub_create (void *hint, struct nn_sockbase **sockbase) { struct nn_xpub *self; self = nn_alloc (sizeof (struct nn_xpub), "socket (xpub)"); alloc_assert (self); nn_xpub_init (self, &nn_xpub_sockbase_vfptr, hint); *sockbase = &self->sockbase; return 0; } int nn_xpub_ispeer (int socktype) { return socktype == NN_SUB ? 1 : 0; } static struct nn_socktype nn_xpub_socktype_struct = { AF_SP_RAW, NN_PUB, NN_SOCKTYPE_FLAG_NORECV, nn_xpub_create, nn_xpub_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_xpub_socktype = &nn_xpub_socktype_struct; nanomsg-0.8-beta/src/protocols/pubsub/xsub.h0000664000175000017500000000255512623652600022116 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_XSUB_INCLUDED #define NN_XSUB_INCLUDED #include "../../protocol.h" extern struct nn_socktype *nn_xsub_socktype; int nn_xsub_create (void *hint, struct nn_sockbase **sockbase); int nn_xsub_ispeer (int socktype); #endif nanomsg-0.8-beta/src/protocols/pubsub/xsub.c0000664000175000017500000001603012623652600022102 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "xsub.h" #include "trie.h" #include "../../nn.h" #include "../../pubsub.h" #include "../utils/fq.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/alloc.h" #include "../../utils/list.h" #include "../../utils/attr.h" struct nn_xsub_data { struct nn_fq_data fq; }; struct nn_xsub { struct nn_sockbase sockbase; struct nn_fq fq; struct nn_trie trie; }; /* Private functions. */ static void nn_xsub_init (struct nn_xsub *self, const struct nn_sockbase_vfptr *vfptr, void *hint); static void nn_xsub_term (struct nn_xsub *self); /* Implementation of nn_sockbase's virtual functions. */ static void nn_xsub_destroy (struct nn_sockbase *self); static int nn_xsub_add (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xsub_rm (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xsub_in (struct nn_sockbase *self, struct nn_pipe *pipe); static void nn_xsub_out (struct nn_sockbase *self, struct nn_pipe *pipe); static int nn_xsub_events (struct nn_sockbase *self); static int nn_xsub_recv (struct nn_sockbase *self, struct nn_msg *msg); static int nn_xsub_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen); static int nn_xsub_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen); static const struct nn_sockbase_vfptr nn_xsub_sockbase_vfptr = { NULL, nn_xsub_destroy, nn_xsub_add, nn_xsub_rm, nn_xsub_in, nn_xsub_out, nn_xsub_events, NULL, nn_xsub_recv, nn_xsub_setopt, nn_xsub_getopt }; static void nn_xsub_init (struct nn_xsub *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_sockbase_init (&self->sockbase, vfptr, hint); nn_fq_init (&self->fq); nn_trie_init (&self->trie); } static void nn_xsub_term (struct nn_xsub *self) { nn_trie_term (&self->trie); nn_fq_term (&self->fq); nn_sockbase_term (&self->sockbase); } void nn_xsub_destroy (struct nn_sockbase *self) { struct nn_xsub *xsub; xsub = nn_cont (self, struct nn_xsub, sockbase); nn_xsub_term (xsub); nn_free (xsub); } static int nn_xsub_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xsub *xsub; struct nn_xsub_data *data; int rcvprio; size_t sz; xsub = nn_cont (self, struct nn_xsub, sockbase); sz = sizeof (rcvprio); nn_pipe_getopt (pipe, NN_SOL_SOCKET, NN_RCVPRIO, &rcvprio, &sz); nn_assert (sz == sizeof (rcvprio)); nn_assert (rcvprio >= 1 && rcvprio <= 16); data = nn_alloc (sizeof (struct nn_xsub_data), "pipe data (sub)"); alloc_assert (data); nn_pipe_setdata (pipe, data); nn_fq_add (&xsub->fq, &data->fq, pipe, rcvprio); return 0; } static void nn_xsub_rm (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xsub *xsub; struct nn_xsub_data *data; xsub = nn_cont (self, struct nn_xsub, sockbase); data = nn_pipe_getdata (pipe); nn_fq_rm (&xsub->fq, &data->fq); nn_free (data); } static void nn_xsub_in (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xsub *xsub; struct nn_xsub_data *data; xsub = nn_cont (self, struct nn_xsub, sockbase); data = nn_pipe_getdata (pipe); nn_fq_in (&xsub->fq, &data->fq); } static void nn_xsub_out (NN_UNUSED struct nn_sockbase *self, NN_UNUSED struct nn_pipe *pipe) { /* We are not going to send any messages until subscription forwarding is implemented, so there's no point is maintaining a list of pipes ready for sending. */ } static int nn_xsub_events (struct nn_sockbase *self) { return nn_fq_can_recv (&nn_cont (self, struct nn_xsub, sockbase)->fq) ? NN_SOCKBASE_EVENT_IN : 0; } static int nn_xsub_recv (struct nn_sockbase *self, struct nn_msg *msg) { int rc; struct nn_xsub *xsub; xsub = nn_cont (self, struct nn_xsub, sockbase); /* Loop while a matching message is found or when there are no more messages to receive. */ while (1) { rc = nn_fq_recv (&xsub->fq, msg, NULL); if (nn_slow (rc == -EAGAIN)) return -EAGAIN; errnum_assert (rc >= 0, -rc); rc = nn_trie_match (&xsub->trie, nn_chunkref_data (&msg->body), nn_chunkref_size (&msg->body)); if (rc == 0) { nn_msg_term (msg); continue; } if (rc == 1) return 0; errnum_assert (0, -rc); } } static int nn_xsub_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen) { int rc; struct nn_xsub *xsub; xsub = nn_cont (self, struct nn_xsub, sockbase); if (level != NN_SUB) return -ENOPROTOOPT; if (option == NN_SUB_SUBSCRIBE) { rc = nn_trie_subscribe (&xsub->trie, optval, optvallen); if (rc >= 0) return 0; return rc; } if (option == NN_SUB_UNSUBSCRIBE) { rc = nn_trie_unsubscribe (&xsub->trie, optval, optvallen); if (rc >= 0) return 0; return rc; } return -ENOPROTOOPT; } static int nn_xsub_getopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED void *optval, NN_UNUSED size_t *optvallen) { return -ENOPROTOOPT; } int nn_xsub_create (void *hint, struct nn_sockbase **sockbase) { struct nn_xsub *self; self = nn_alloc (sizeof (struct nn_xsub), "socket (xsub)"); alloc_assert (self); nn_xsub_init (self, &nn_xsub_sockbase_vfptr, hint); *sockbase = &self->sockbase; return 0; } int nn_xsub_ispeer (int socktype) { return socktype == NN_PUB ? 1 : 0; } static struct nn_socktype nn_xsub_socktype_struct = { AF_SP_RAW, NN_SUB, NN_SOCKTYPE_FLAG_NOSEND, nn_xsub_create, nn_xsub_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_xsub_socktype = &nn_xsub_socktype_struct; nanomsg-0.8-beta/src/protocols/reqrep/0000775000175000017500000000000012623652617020763 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/protocols/reqrep/req.h0000664000175000017500000000605212623652600021716 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_REQ_INCLUDED #define NN_REQ_INCLUDED #include "xreq.h" #include "task.h" #include "../../protocol.h" #include "../../aio/fsm.h" struct nn_req { /* The base class. Raw REQ socket. */ struct nn_xreq xreq; /* The state machine. */ struct nn_fsm fsm; int state; /* Last request ID assigned. */ uint32_t lastid; /* Protocol-specific socket options. */ int resend_ivl; /* The request being processed. */ struct nn_task task; }; extern struct nn_socktype *nn_req_socktype; /* Some users may want to extend the REQ protocol similar to how REQ extends XREQ. Expose these methods to improve extensibility. */ void nn_req_init (struct nn_req *self, const struct nn_sockbase_vfptr *vfptr, void *hint); void nn_req_term (struct nn_req *self); int nn_req_inprogress (struct nn_req *self); void nn_req_handler (struct nn_fsm *self, int src, int type, void *srcptr); void nn_req_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); void nn_req_action_send (struct nn_req *self, int allow_delay); /* Implementation of nn_sockbase's virtual functions. */ void nn_req_stop (struct nn_sockbase *self); void nn_req_destroy (struct nn_sockbase *self); void nn_req_in (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_req_out (struct nn_sockbase *self, struct nn_pipe *pipe); int nn_req_events (struct nn_sockbase *self); int nn_req_csend (struct nn_sockbase *self, struct nn_msg *msg); void nn_req_rm (struct nn_sockbase *self, struct nn_pipe *pipe); int nn_req_crecv (struct nn_sockbase *self, struct nn_msg *msg); int nn_req_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen); int nn_req_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen); int nn_req_csend (struct nn_sockbase *self, struct nn_msg *msg); int nn_req_crecv (struct nn_sockbase *self, struct nn_msg *msg); #endif nanomsg-0.8-beta/src/protocols/reqrep/req.c0000664000175000017500000005163312623652600021716 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "req.h" #include "xreq.h" #include "../../nn.h" #include "../../reqrep.h" #include "../../aio/fsm.h" #include "../../aio/timer.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/alloc.h" #include "../../utils/random.h" #include "../../utils/wire.h" #include "../../utils/list.h" #include "../../utils/int.h" #include "../../utils/attr.h" #include #include /* Default re-send interval is 1 minute. */ #define NN_REQ_DEFAULT_RESEND_IVL 60000 #define NN_REQ_STATE_IDLE 1 #define NN_REQ_STATE_PASSIVE 2 #define NN_REQ_STATE_DELAYED 3 #define NN_REQ_STATE_ACTIVE 4 #define NN_REQ_STATE_TIMED_OUT 5 #define NN_REQ_STATE_CANCELLING 6 #define NN_REQ_STATE_STOPPING_TIMER 7 #define NN_REQ_STATE_DONE 8 #define NN_REQ_STATE_STOPPING 9 #define NN_REQ_ACTION_START 1 #define NN_REQ_ACTION_IN 2 #define NN_REQ_ACTION_OUT 3 #define NN_REQ_ACTION_SENT 4 #define NN_REQ_ACTION_RECEIVED 5 #define NN_REQ_ACTION_PIPE_RM 6 #define NN_REQ_SRC_RESEND_TIMER 1 static const struct nn_sockbase_vfptr nn_req_sockbase_vfptr = { nn_req_stop, nn_req_destroy, nn_xreq_add, nn_req_rm, nn_req_in, nn_req_out, nn_req_events, nn_req_csend, nn_req_crecv, nn_req_setopt, nn_req_getopt }; void nn_req_init (struct nn_req *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_req_handle hndl; nn_xreq_init (&self->xreq, vfptr, hint); nn_fsm_init_root (&self->fsm, nn_req_handler, nn_req_shutdown, nn_sockbase_getctx (&self->xreq.sockbase)); self->state = NN_REQ_STATE_IDLE; /* Start assigning request IDs beginning with a random number. This way there should be no key clashes even if the executable is re-started. */ nn_random_generate (&self->lastid, sizeof (self->lastid)); self->task.sent_to = NULL; nn_msg_init (&self->task.request, 0); nn_msg_init (&self->task.reply, 0); nn_timer_init (&self->task.timer, NN_REQ_SRC_RESEND_TIMER, &self->fsm); self->resend_ivl = NN_REQ_DEFAULT_RESEND_IVL; /* For now, handle is empty. */ memset (&hndl, 0, sizeof (hndl)); nn_task_init (&self->task, self->lastid, hndl); /* Start the state machine. */ nn_fsm_start (&self->fsm); } void nn_req_term (struct nn_req *self) { nn_timer_term (&self->task.timer); nn_task_term (&self->task); nn_msg_term (&self->task.reply); nn_msg_term (&self->task.request); nn_fsm_term (&self->fsm); nn_xreq_term (&self->xreq); } void nn_req_stop (struct nn_sockbase *self) { struct nn_req *req; req = nn_cont (self, struct nn_req, xreq.sockbase); nn_fsm_stop (&req->fsm); } void nn_req_destroy (struct nn_sockbase *self) { struct nn_req *req; req = nn_cont (self, struct nn_req, xreq.sockbase); nn_req_term (req); nn_free (req); } int nn_req_inprogress (struct nn_req *self) { /* Return 1 if there's a request submitted. 0 otherwise. */ return self->state == NN_REQ_STATE_IDLE || self->state == NN_REQ_STATE_PASSIVE || self->state == NN_REQ_STATE_STOPPING ? 0 : 1; } void nn_req_in (struct nn_sockbase *self, struct nn_pipe *pipe) { int rc; struct nn_req *req; uint32_t reqid; req = nn_cont (self, struct nn_req, xreq.sockbase); /* Pass the pipe to the raw REQ socket. */ nn_xreq_in (&req->xreq.sockbase, pipe); while (1) { /* Get new reply. */ rc = nn_xreq_recv (&req->xreq.sockbase, &req->task.reply); if (nn_slow (rc == -EAGAIN)) return; errnum_assert (rc == 0, -rc); /* No request was sent. Getting a reply doesn't make sense. */ if (nn_slow (!nn_req_inprogress (req))) { nn_msg_term (&req->task.reply); continue; } /* Ignore malformed replies. */ if (nn_slow (nn_chunkref_size (&req->task.reply.sphdr) != sizeof (uint32_t))) { nn_msg_term (&req->task.reply); continue; } /* Ignore replies with incorrect request IDs. */ reqid = nn_getl (nn_chunkref_data (&req->task.reply.sphdr)); if (nn_slow (!(reqid & 0x80000000))) { nn_msg_term (&req->task.reply); continue; } if (nn_slow (reqid != (req->task.id | 0x80000000))) { nn_msg_term (&req->task.reply); continue; } /* Trim the request ID. */ nn_chunkref_term (&req->task.reply.sphdr); nn_chunkref_init (&req->task.reply.sphdr, 0); /* TODO: Deallocate the request here? */ /* Notify the state machine. */ if (req->state == NN_REQ_STATE_ACTIVE) nn_fsm_action (&req->fsm, NN_REQ_ACTION_IN); return; } } void nn_req_out (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_req *req; req = nn_cont (self, struct nn_req, xreq.sockbase); /* Add the pipe to the underlying raw socket. */ nn_xreq_out (&req->xreq.sockbase, pipe); /* Notify the state machine. */ if (req->state == NN_REQ_STATE_DELAYED) nn_fsm_action (&req->fsm, NN_REQ_ACTION_OUT); } int nn_req_events (struct nn_sockbase *self) { int rc; struct nn_req *req; req = nn_cont (self, struct nn_req, xreq.sockbase); /* OUT is signalled all the time because sending a request while another one is being processed cancels the old one. */ rc = NN_SOCKBASE_EVENT_OUT; /* In DONE state the reply is stored in 'reply' field. */ if (req->state == NN_REQ_STATE_DONE) rc |= NN_SOCKBASE_EVENT_IN; return rc; } int nn_req_send (NN_UNUSED int s, NN_UNUSED nn_req_handle hndl, NN_UNUSED const void *buf, NN_UNUSED size_t len, NN_UNUSED int flags) { nn_assert (0); } int nn_req_csend (struct nn_sockbase *self, struct nn_msg *msg) { struct nn_req *req; req = nn_cont (self, struct nn_req, xreq.sockbase); /* Generate new request ID for the new request and put it into message header. The most important bit is set to 1 to indicate that this is the bottom of the backtrace stack. */ ++req->task.id; nn_assert (nn_chunkref_size (&msg->sphdr) == 0); nn_chunkref_term (&msg->sphdr); nn_chunkref_init (&msg->sphdr, 4); nn_putl (nn_chunkref_data (&msg->sphdr), req->task.id | 0x80000000); /* Store the message so that it can be re-sent if there's no reply. */ nn_msg_term (&req->task.request); nn_msg_mv (&req->task.request, msg); /* Notify the state machine. */ nn_fsm_action (&req->fsm, NN_REQ_ACTION_SENT); return 0; } int nn_req_recv (NN_UNUSED int s, NN_UNUSED nn_req_handle *hndl, NN_UNUSED void *buf, NN_UNUSED size_t len, NN_UNUSED int flags) { nn_assert (0); } int nn_req_crecv (struct nn_sockbase *self, struct nn_msg *msg) { struct nn_req *req; req = nn_cont (self, struct nn_req, xreq.sockbase); /* No request was sent. Waiting for a reply doesn't make sense. */ if (nn_slow (!nn_req_inprogress (req))) return -EFSM; /* If reply was not yet recieved, wait further. */ if (nn_slow (req->state != NN_REQ_STATE_DONE)) return -EAGAIN; /* If the reply was already received, just pass it to the caller. */ nn_msg_mv (msg, &req->task.reply); nn_msg_init (&req->task.reply, 0); /* Notify the state machine. */ nn_fsm_action (&req->fsm, NN_REQ_ACTION_RECEIVED); return 0; } int nn_req_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen) { struct nn_req *req; req = nn_cont (self, struct nn_req, xreq.sockbase); if (level != NN_REQ) return -ENOPROTOOPT; if (option == NN_REQ_RESEND_IVL) { if (nn_slow (optvallen != sizeof (int))) return -EINVAL; req->resend_ivl = *(int*) optval; return 0; } return -ENOPROTOOPT; } int nn_req_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen) { struct nn_req *req; req = nn_cont (self, struct nn_req, xreq.sockbase); if (level != NN_REQ) return -ENOPROTOOPT; if (option == NN_REQ_RESEND_IVL) { if (nn_slow (*optvallen < sizeof (int))) return -EINVAL; *(int*) optval = req->resend_ivl; *optvallen = sizeof (int); return 0; } return -ENOPROTOOPT; } void nn_req_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_req *req; req = nn_cont (self, struct nn_req, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { nn_timer_stop (&req->task.timer); req->state = NN_REQ_STATE_STOPPING; } if (nn_slow (req->state == NN_REQ_STATE_STOPPING)) { if (!nn_timer_isidle (&req->task.timer)) return; req->state = NN_REQ_STATE_IDLE; nn_fsm_stopped_noevent (&req->fsm); nn_sockbase_stopped (&req->xreq.sockbase); return; } nn_fsm_bad_state(req->state, src, type); } void nn_req_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_req *req; req = nn_cont (self, struct nn_req, fsm); switch (req->state) { /******************************************************************************/ /* IDLE state. */ /* The socket was created recently. Intermediate state. */ /* Pass straight to the PASSIVE state. */ /******************************************************************************/ case NN_REQ_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: req->state = NN_REQ_STATE_PASSIVE; return; default: nn_fsm_bad_action (req->state, src, type); } default: nn_fsm_bad_source (req->state, src, type); } /******************************************************************************/ /* PASSIVE state. */ /* No request is submitted. */ /******************************************************************************/ case NN_REQ_STATE_PASSIVE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_REQ_ACTION_SENT: nn_req_action_send (req, 1); return; default: nn_fsm_bad_action (req->state, src, type); } default: nn_fsm_bad_source (req->state, src, type); } /******************************************************************************/ /* DELAYED state. */ /* Request was submitted but it could not be sent to the network because */ /* there was no peer available at the moment. Now we are waiting for the */ /* peer to arrive to send the request to it. */ /******************************************************************************/ case NN_REQ_STATE_DELAYED: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_REQ_ACTION_OUT: nn_req_action_send (req, 0); return; case NN_REQ_ACTION_SENT: return; default: nn_fsm_bad_action (req->state, src, type); } default: nn_fsm_bad_source (req->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /* Request was submitted. Waiting for reply. */ /******************************************************************************/ case NN_REQ_STATE_ACTIVE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_REQ_ACTION_IN: /* Reply arrived. */ nn_timer_stop (&req->task.timer); req->task.sent_to = NULL; req->state = NN_REQ_STATE_STOPPING_TIMER; return; case NN_REQ_ACTION_SENT: /* New request was sent while the old one was still being processed. Cancel the old request first. */ nn_timer_stop (&req->task.timer); req->task.sent_to = NULL; req->state = NN_REQ_STATE_CANCELLING; return; case NN_REQ_ACTION_PIPE_RM: /* Pipe that we sent request to is removed */ nn_timer_stop (&req->task.timer); req->task.sent_to = NULL; /* Pretend we timed out so request resent immediately */ req->state = NN_REQ_STATE_TIMED_OUT; return; default: nn_fsm_bad_action (req->state, src, type); } case NN_REQ_SRC_RESEND_TIMER: switch (type) { case NN_TIMER_TIMEOUT: nn_timer_stop (&req->task.timer); req->task.sent_to = NULL; req->state = NN_REQ_STATE_TIMED_OUT; return; default: nn_fsm_bad_action (req->state, src, type); } default: nn_fsm_bad_source (req->state, src, type); } /******************************************************************************/ /* TIMED_OUT state. */ /* Waiting for reply has timed out. Stopping the timer. Afterwards, we'll */ /* re-send the request. */ /******************************************************************************/ case NN_REQ_STATE_TIMED_OUT: switch (src) { case NN_REQ_SRC_RESEND_TIMER: switch (type) { case NN_TIMER_STOPPED: nn_req_action_send (req, 1); return; default: nn_fsm_bad_action (req->state, src, type); } case NN_FSM_ACTION: switch (type) { case NN_REQ_ACTION_SENT: req->state = NN_REQ_STATE_CANCELLING; return; default: nn_fsm_bad_action (req->state, src, type); } default: nn_fsm_bad_source (req->state, src, type); } /******************************************************************************/ /* CANCELLING state. */ /* Request was canceled. Waiting till the timer is stopped. Note that */ /* cancelling is done by sending a new request. Thus there's already */ /* a request waiting to be sent in this state. */ /******************************************************************************/ case NN_REQ_STATE_CANCELLING: switch (src) { case NN_REQ_SRC_RESEND_TIMER: switch (type) { case NN_TIMER_STOPPED: /* Timer is stopped. Now we can send the delayed request. */ nn_req_action_send (req, 1); return; default: nn_fsm_bad_action (req->state, src, type); } case NN_FSM_ACTION: switch (type) { case NN_REQ_ACTION_SENT: /* No need to do anything here. Old delayed request is just replaced by the new one that will be sent once the timer is closed. */ return; default: nn_fsm_bad_action (req->state, src, type); } default: nn_fsm_bad_source (req->state, src, type); } /******************************************************************************/ /* STOPPING_TIMER state. */ /* Reply was delivered. Waiting till the timer is stopped. */ /******************************************************************************/ case NN_REQ_STATE_STOPPING_TIMER: switch (src) { case NN_REQ_SRC_RESEND_TIMER: switch (type) { case NN_TIMER_STOPPED: req->state = NN_REQ_STATE_DONE; return; default: nn_fsm_bad_action (req->state, src, type); } case NN_FSM_ACTION: switch (type) { case NN_REQ_ACTION_SENT: req->state = NN_REQ_STATE_CANCELLING; return; default: nn_fsm_bad_action (req->state, src, type); } default: nn_fsm_bad_source (req->state, src, type); } /******************************************************************************/ /* DONE state. */ /* Reply was received but not yet retrieved by the user. */ /******************************************************************************/ case NN_REQ_STATE_DONE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_REQ_ACTION_RECEIVED: req->state = NN_REQ_STATE_PASSIVE; return; case NN_REQ_ACTION_SENT: nn_req_action_send (req, 1); return; default: nn_fsm_bad_action (req->state, src, type); } default: nn_fsm_bad_source (req->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (req->state, src, type); } } /******************************************************************************/ /* State machine actions. */ /******************************************************************************/ void nn_req_action_send (struct nn_req *self, int allow_delay) { int rc; struct nn_msg msg; struct nn_pipe *to; /* Send the request. */ nn_msg_cp (&msg, &self->task.request); rc = nn_xreq_send_to (&self->xreq.sockbase, &msg, &to); /* If the request cannot be sent at the moment wait till new outbound pipe arrives. */ if (nn_slow (rc == -EAGAIN)) { nn_assert (allow_delay == 1); nn_msg_term (&msg); self->state = NN_REQ_STATE_DELAYED; return; } /* Request was successfully sent. Set up the re-send timer in case the request gets lost somewhere further out in the topology. */ if (nn_fast (rc == 0)) { nn_timer_start (&self->task.timer, self->resend_ivl); nn_assert (to); self->task.sent_to = to; self->state = NN_REQ_STATE_ACTIVE; return; } /* Unexpected error. */ errnum_assert (0, -rc); } static int nn_req_create (void *hint, struct nn_sockbase **sockbase) { struct nn_req *self; self = nn_alloc (sizeof (struct nn_req), "socket (req)"); alloc_assert (self); nn_req_init (self, &nn_req_sockbase_vfptr, hint); *sockbase = &self->xreq.sockbase; return 0; } void nn_req_rm (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_req *req; req = nn_cont (self, struct nn_req, xreq.sockbase); nn_xreq_rm (self, pipe); if (nn_slow (pipe == req->task.sent_to)) { nn_fsm_action (&req->fsm, NN_REQ_ACTION_PIPE_RM); } } static struct nn_socktype nn_req_socktype_struct = { AF_SP, NN_REQ, 0, nn_req_create, nn_xreq_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_req_socktype = &nn_req_socktype_struct; nanomsg-0.8-beta/src/protocols/reqrep/rep.h0000664000175000017500000000364312623652600021720 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_REP_INCLUDED #define NN_REP_INCLUDED #include "../../protocol.h" #include "xrep.h" extern struct nn_socktype *nn_rep_socktype; struct nn_rep { struct nn_xrep xrep; uint32_t flags; struct nn_chunkref backtrace; }; /* Some users may want to extend the REP protocol similar to how REP extends XREP. Expose these methods to improve extensibility. */ void nn_rep_init (struct nn_rep *self, const struct nn_sockbase_vfptr *vfptr, void *hint); void nn_rep_term (struct nn_rep *self); /* Implementation of nn_sockbase's virtual functions. */ void nn_rep_destroy (struct nn_sockbase *self); int nn_rep_events (struct nn_sockbase *self); int nn_rep_send (struct nn_sockbase *self, struct nn_msg *msg); int nn_rep_recv (struct nn_sockbase *self, struct nn_msg *msg); #endif nanomsg-0.8-beta/src/protocols/reqrep/rep.c0000664000175000017500000001075012623652600021710 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "rep.h" #include "xrep.h" #include "../../nn.h" #include "../../reqrep.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/alloc.h" #include "../../utils/chunkref.h" #include "../../utils/wire.h" #include "../../utils/list.h" #include "../../utils/int.h" #include #include #define NN_REP_INPROGRESS 1 static const struct nn_sockbase_vfptr nn_rep_sockbase_vfptr = { NULL, nn_rep_destroy, nn_xrep_add, nn_xrep_rm, nn_xrep_in, nn_xrep_out, nn_rep_events, nn_rep_send, nn_rep_recv, nn_xrep_setopt, nn_xrep_getopt }; void nn_rep_init (struct nn_rep *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_xrep_init (&self->xrep, vfptr, hint); self->flags = 0; } void nn_rep_term (struct nn_rep *self) { if (self->flags & NN_REP_INPROGRESS) nn_chunkref_term (&self->backtrace); nn_xrep_term (&self->xrep); } void nn_rep_destroy (struct nn_sockbase *self) { struct nn_rep *rep; rep = nn_cont (self, struct nn_rep, xrep.sockbase); nn_rep_term (rep); nn_free (rep); } int nn_rep_events (struct nn_sockbase *self) { struct nn_rep *rep; int events; rep = nn_cont (self, struct nn_rep, xrep.sockbase); events = nn_xrep_events (&rep->xrep.sockbase); if (!(rep->flags & NN_REP_INPROGRESS)) events &= ~NN_SOCKBASE_EVENT_OUT; return events; } int nn_rep_send (struct nn_sockbase *self, struct nn_msg *msg) { int rc; struct nn_rep *rep; rep = nn_cont (self, struct nn_rep, xrep.sockbase); /* If no request was received, there's nowhere to send the reply to. */ if (nn_slow (!(rep->flags & NN_REP_INPROGRESS))) return -EFSM; /* Move the stored backtrace into the message header. */ nn_assert (nn_chunkref_size (&msg->sphdr) == 0); nn_chunkref_term (&msg->sphdr); nn_chunkref_mv (&msg->sphdr, &rep->backtrace); rep->flags &= ~NN_REP_INPROGRESS; /* Send the reply. If it cannot be sent because of pushback, drop it silently. */ rc = nn_xrep_send (&rep->xrep.sockbase, msg); errnum_assert (rc == 0 || rc == -EAGAIN, -rc); return 0; } int nn_rep_recv (struct nn_sockbase *self, struct nn_msg *msg) { int rc; struct nn_rep *rep; rep = nn_cont (self, struct nn_rep, xrep.sockbase); /* If a request is already being processed, cancel it. */ if (nn_slow (rep->flags & NN_REP_INPROGRESS)) { nn_chunkref_term (&rep->backtrace); rep->flags &= ~NN_REP_INPROGRESS; } /* Receive the request. */ rc = nn_xrep_recv (&rep->xrep.sockbase, msg); if (nn_slow (rc == -EAGAIN)) return -EAGAIN; errnum_assert (rc == 0, -rc); /* Store the backtrace. */ nn_chunkref_mv (&rep->backtrace, &msg->sphdr); nn_chunkref_init (&msg->sphdr, 0); rep->flags |= NN_REP_INPROGRESS; return 0; } static int nn_rep_create (void *hint, struct nn_sockbase **sockbase) { struct nn_rep *self; self = nn_alloc (sizeof (struct nn_rep), "socket (rep)"); alloc_assert (self); nn_rep_init (self, &nn_rep_sockbase_vfptr, hint); *sockbase = &self->xrep.sockbase; return 0; } static struct nn_socktype nn_rep_socktype_struct = { AF_SP, NN_REP, 0, nn_rep_create, nn_xrep_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_rep_socktype = &nn_rep_socktype_struct; nanomsg-0.8-beta/src/protocols/reqrep/task.h0000664000175000017500000000417312623652600022073 0ustar00travistravis00000000000000/* Copyright (c) 2014 Martin Sustrik 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. */ #ifndef NN_TASK_INCLUDED #define NN_TASK_INCLUDED #include "../../reqrep.h" #include "../../aio/fsm.h" #include "../../aio/timer.h" #include "../../utils/msg.h" #include "../../utils/int.h" struct nn_task { /* ID of the request being currently processed. Replies for different requests are considered stale and simply dropped. */ uint32_t id; /* User-defined handle of the task. */ nn_req_handle hndl; /* Stored request, so that it can be re-sent if needed. */ struct nn_msg request; /* Stored reply, so that user can retrieve it later on. */ struct nn_msg reply; /* Timer used to wait while request should be re-sent. */ struct nn_timer timer; /* Pipe the current request has been sent to. This is an optimisation so that request can be re-sent immediately if the pipe disappears. */ struct nn_pipe *sent_to; }; void nn_task_init (struct nn_task *self, uint32_t id, nn_req_handle hndl); void nn_task_term (struct nn_task *self); #endif nanomsg-0.8-beta/src/protocols/reqrep/task.c0000664000175000017500000000254112623652600022063 0ustar00travistravis00000000000000/* Copyright (c) 2014 Martin Sustrik 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 "task.h" #include "../../utils/attr.h" void nn_task_init (struct nn_task *self, uint32_t id, nn_req_handle hndl) { self->id = id; self->hndl = hndl; } void nn_task_term (NN_UNUSED struct nn_task *self) { } nanomsg-0.8-beta/src/protocols/reqrep/xrep.h0000664000175000017500000000520212623652600022101 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_XREP_INCLUDED #define NN_XREP_INCLUDED #include "../../protocol.h" #include "../../utils/hash.h" #include "../../utils/int.h" #include "../utils/fq.h" #include #define NN_XREP_OUT 1 struct nn_xrep_data { struct nn_pipe *pipe; struct nn_hash_item outitem; struct nn_fq_data initem; uint32_t flags; }; struct nn_xrep { struct nn_sockbase sockbase; /* Key to be assigned to the next added pipe. */ uint32_t next_key; /* Map of all registered pipes indexed by the peer ID. */ struct nn_hash outpipes; /* Fair-queuer to get messages from. */ struct nn_fq inpipes; }; void nn_xrep_init (struct nn_xrep *self, const struct nn_sockbase_vfptr *vfptr, void *hint); void nn_xrep_term (struct nn_xrep *self); int nn_xrep_add (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xrep_rm (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xrep_in (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xrep_out (struct nn_sockbase *self, struct nn_pipe *pipe); int nn_xrep_events (struct nn_sockbase *self); int nn_xrep_send (struct nn_sockbase *self, struct nn_msg *msg); int nn_xrep_recv (struct nn_sockbase *self, struct nn_msg *msg); int nn_xrep_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen); int nn_xrep_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen); int nn_xrep_ispeer (int socktype); extern struct nn_socktype *nn_xrep_socktype; #endif nanomsg-0.8-beta/src/protocols/reqrep/xrep.c0000664000175000017500000002027212623652600022100 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik 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 "xrep.h" #include "../../nn.h" #include "../../reqrep.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/alloc.h" #include "../../utils/random.h" #include "../../utils/wire.h" #include "../../utils/list.h" #include "../../utils/attr.h" #include /* Private functions. */ static void nn_xrep_destroy (struct nn_sockbase *self); static const struct nn_sockbase_vfptr nn_xrep_sockbase_vfptr = { NULL, nn_xrep_destroy, nn_xrep_add, nn_xrep_rm, nn_xrep_in, nn_xrep_out, nn_xrep_events, nn_xrep_send, nn_xrep_recv, nn_xrep_setopt, nn_xrep_getopt }; void nn_xrep_init (struct nn_xrep *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_sockbase_init (&self->sockbase, vfptr, hint); /* Start assigning keys beginning with a random number. This way there are no key clashes even if the executable is re-started. */ nn_random_generate (&self->next_key, sizeof (self->next_key)); nn_hash_init (&self->outpipes); nn_fq_init (&self->inpipes); } void nn_xrep_term (struct nn_xrep *self) { nn_fq_term (&self->inpipes); nn_hash_term (&self->outpipes); nn_sockbase_term (&self->sockbase); } static void nn_xrep_destroy (struct nn_sockbase *self) { struct nn_xrep *xrep; xrep = nn_cont (self, struct nn_xrep, sockbase); nn_xrep_term (xrep); nn_free (xrep); } int nn_xrep_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xrep *xrep; struct nn_xrep_data *data; int rcvprio; size_t sz; xrep = nn_cont (self, struct nn_xrep, sockbase); sz = sizeof (rcvprio); nn_pipe_getopt (pipe, NN_SOL_SOCKET, NN_RCVPRIO, &rcvprio, &sz); nn_assert (sz == sizeof (rcvprio)); nn_assert (rcvprio >= 1 && rcvprio <= 16); data = nn_alloc (sizeof (struct nn_xrep_data), "pipe data (xrep)"); alloc_assert (data); data->pipe = pipe; nn_hash_item_init (&data->outitem); data->flags = 0; nn_hash_insert (&xrep->outpipes, xrep->next_key & 0x7fffffff, &data->outitem); ++xrep->next_key; nn_fq_add (&xrep->inpipes, &data->initem, pipe, rcvprio); nn_pipe_setdata (pipe, data); return 0; } void nn_xrep_rm (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xrep *xrep; struct nn_xrep_data *data; xrep = nn_cont (self, struct nn_xrep, sockbase); data = nn_pipe_getdata (pipe); nn_fq_rm (&xrep->inpipes, &data->initem); nn_hash_erase (&xrep->outpipes, &data->outitem); nn_hash_item_term (&data->outitem); nn_free (data); } void nn_xrep_in (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xrep *xrep; struct nn_xrep_data *data; xrep = nn_cont (self, struct nn_xrep, sockbase); data = nn_pipe_getdata (pipe); nn_fq_in (&xrep->inpipes, &data->initem); } void nn_xrep_out (NN_UNUSED struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xrep_data *data; data = nn_pipe_getdata (pipe); data->flags |= NN_XREP_OUT; } int nn_xrep_events (struct nn_sockbase *self) { return (nn_fq_can_recv (&nn_cont (self, struct nn_xrep, sockbase)->inpipes) ? NN_SOCKBASE_EVENT_IN : 0) | NN_SOCKBASE_EVENT_OUT; } int nn_xrep_send (struct nn_sockbase *self, struct nn_msg *msg) { int rc; uint32_t key; struct nn_xrep *xrep; struct nn_xrep_data *data; xrep = nn_cont (self, struct nn_xrep, sockbase); /* We treat invalid peer ID as if the peer was non-existent. */ if (nn_slow (nn_chunkref_size (&msg->sphdr) < sizeof (uint32_t))) { nn_msg_term (msg); return 0; } /* Retrieve the destination peer ID. Trim it from the header. */ key = nn_getl (nn_chunkref_data (&msg->sphdr)); nn_chunkref_trim (&msg->sphdr, 4); /* Find the appropriate pipe to send the message to. If there's none, or if it's not ready for sending, silently drop the message. */ data = nn_cont (nn_hash_get (&xrep->outpipes, key), struct nn_xrep_data, outitem); if (!data || !(data->flags & NN_XREP_OUT)) { nn_msg_term (msg); return 0; } /* Send the message. */ rc = nn_pipe_send (data->pipe, msg); errnum_assert (rc >= 0, -rc); if (rc & NN_PIPE_RELEASE) data->flags &= ~NN_XREP_OUT; return 0; } int nn_xrep_recv (struct nn_sockbase *self, struct nn_msg *msg) { int rc; struct nn_xrep *xrep; struct nn_pipe *pipe; int i; void *data; size_t sz; struct nn_chunkref ref; struct nn_xrep_data *pipedata; xrep = nn_cont (self, struct nn_xrep, sockbase); rc = nn_fq_recv (&xrep->inpipes, msg, &pipe); if (nn_slow (rc < 0)) return rc; if (!(rc & NN_PIPE_PARSED)) { /* Determine the size of the message header. */ data = nn_chunkref_data (&msg->body); sz = nn_chunkref_size (&msg->body); i = 0; while (1) { /* Ignore the malformed requests without the bottom of the stack. */ if (nn_slow ((i + 1) * sizeof (uint32_t) > sz)) { nn_msg_term (msg); return -EAGAIN; } /* If the bottom of the backtrace stack is reached, proceed. */ if (nn_getl ((uint8_t*)(((uint32_t*) data) + i)) & 0x80000000) break; ++i; } ++i; /* Split the header and the body. */ nn_assert (nn_chunkref_size (&msg->sphdr) == 0); nn_chunkref_term (&msg->sphdr); nn_chunkref_init (&msg->sphdr, i * sizeof (uint32_t)); memcpy (nn_chunkref_data (&msg->sphdr), data, i * sizeof (uint32_t)); nn_chunkref_trim (&msg->body, i * sizeof (uint32_t)); } /* Prepend the header by the pipe key. */ pipedata = nn_pipe_getdata (pipe); nn_chunkref_init (&ref, nn_chunkref_size (&msg->sphdr) + sizeof (uint32_t)); nn_putl (nn_chunkref_data (&ref), pipedata->outitem.key); memcpy (((uint8_t*) nn_chunkref_data (&ref)) + sizeof (uint32_t), nn_chunkref_data (&msg->sphdr), nn_chunkref_size (&msg->sphdr)); nn_chunkref_term (&msg->sphdr); nn_chunkref_mv (&msg->sphdr, &ref); return 0; } int nn_xrep_setopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED const void *optval, NN_UNUSED size_t optvallen) { return -ENOPROTOOPT; } int nn_xrep_getopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED void *optval, NN_UNUSED size_t *optvallen) { return -ENOPROTOOPT; } static int nn_xrep_create (void *hint, struct nn_sockbase **sockbase) { struct nn_xrep *self; self = nn_alloc (sizeof (struct nn_xrep), "socket (xrep)"); alloc_assert (self); nn_xrep_init (self, &nn_xrep_sockbase_vfptr, hint); *sockbase = &self->sockbase; return 0; } int nn_xrep_ispeer (int socktype) { return socktype == NN_REQ ? 1 : 0; } static struct nn_socktype nn_xrep_socktype_struct = { AF_SP_RAW, NN_REP, 0, nn_xrep_create, nn_xrep_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_xrep_socktype = &nn_xrep_socktype_struct; nanomsg-0.8-beta/src/protocols/reqrep/xreq.h0000664000175000017500000000447712623652600022117 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_XREQ_INCLUDED #define NN_XREQ_INCLUDED #include "../../protocol.h" #include "../utils/lb.h" #include "../utils/fq.h" struct nn_xreq { struct nn_sockbase sockbase; struct nn_lb lb; struct nn_fq fq; }; void nn_xreq_init (struct nn_xreq *self, const struct nn_sockbase_vfptr *vfptr, void *hint); void nn_xreq_term (struct nn_xreq *self); int nn_xreq_add (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xreq_rm (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xreq_in (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xreq_out (struct nn_sockbase *self, struct nn_pipe *pipe); int nn_xreq_events (struct nn_sockbase *self); int nn_xreq_send (struct nn_sockbase *self, struct nn_msg *msg); int nn_xreq_send_to (struct nn_sockbase *self, struct nn_msg *msg, struct nn_pipe **to); int nn_xreq_recv (struct nn_sockbase *self, struct nn_msg *msg); int nn_xreq_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen); int nn_xreq_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen); int nn_xreq_ispeer (int socktype); extern struct nn_socktype *nn_xreq_socktype; #endif nanomsg-0.8-beta/src/protocols/reqrep/xreq.c0000664000175000017500000001531712623652600022105 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik 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 "xreq.h" #include "../../nn.h" #include "../../reqrep.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/alloc.h" #include "../../utils/list.h" #include "../../utils/attr.h" struct nn_xreq_data { struct nn_lb_data lb; struct nn_fq_data fq; }; /* Private functions. */ static void nn_xreq_destroy (struct nn_sockbase *self); static const struct nn_sockbase_vfptr nn_xreq_sockbase_vfptr = { NULL, nn_xreq_destroy, nn_xreq_add, nn_xreq_rm, nn_xreq_in, nn_xreq_out, nn_xreq_events, nn_xreq_send, nn_xreq_recv, nn_xreq_setopt, nn_xreq_getopt }; void nn_xreq_init (struct nn_xreq *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_sockbase_init (&self->sockbase, vfptr, hint); nn_lb_init (&self->lb); nn_fq_init (&self->fq); } void nn_xreq_term (struct nn_xreq *self) { nn_fq_term (&self->fq); nn_lb_term (&self->lb); nn_sockbase_term (&self->sockbase); } static void nn_xreq_destroy (struct nn_sockbase *self) { struct nn_xreq *xreq; xreq = nn_cont (self, struct nn_xreq, sockbase); nn_xreq_term (xreq); nn_free (xreq); } int nn_xreq_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xreq *xreq; struct nn_xreq_data *data; int sndprio; int rcvprio; size_t sz; xreq = nn_cont (self, struct nn_xreq, sockbase); sz = sizeof (sndprio); nn_pipe_getopt (pipe, NN_SOL_SOCKET, NN_SNDPRIO, &sndprio, &sz); nn_assert (sz == sizeof (sndprio)); nn_assert (sndprio >= 1 && sndprio <= 16); sz = sizeof (rcvprio); nn_pipe_getopt (pipe, NN_SOL_SOCKET, NN_RCVPRIO, &rcvprio, &sz); nn_assert (sz == sizeof (rcvprio)); nn_assert (rcvprio >= 1 && rcvprio <= 16); data = nn_alloc (sizeof (struct nn_xreq_data), "pipe data (req)"); alloc_assert (data); nn_pipe_setdata (pipe, data); nn_lb_add (&xreq->lb, &data->lb, pipe, sndprio); nn_fq_add (&xreq->fq, &data->fq, pipe, rcvprio); return 0; } void nn_xreq_rm (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xreq *xreq; struct nn_xreq_data *data; xreq = nn_cont (self, struct nn_xreq, sockbase); data = nn_pipe_getdata (pipe); nn_lb_rm (&xreq->lb, &data->lb); nn_fq_rm (&xreq->fq, &data->fq); nn_free (data); nn_sockbase_stat_increment (self, NN_STAT_CURRENT_SND_PRIORITY, nn_lb_get_priority (&xreq->lb)); } void nn_xreq_in (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xreq *xreq; struct nn_xreq_data *data; xreq = nn_cont (self, struct nn_xreq, sockbase); data = nn_pipe_getdata (pipe); nn_fq_in (&xreq->fq, &data->fq); } void nn_xreq_out (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xreq *xreq; struct nn_xreq_data *data; xreq = nn_cont (self, struct nn_xreq, sockbase); data = nn_pipe_getdata (pipe); nn_lb_out (&xreq->lb, &data->lb); nn_sockbase_stat_increment (self, NN_STAT_CURRENT_SND_PRIORITY, nn_lb_get_priority (&xreq->lb)); } int nn_xreq_events (struct nn_sockbase *self) { struct nn_xreq *xreq; xreq = nn_cont (self, struct nn_xreq, sockbase); return (nn_fq_can_recv (&xreq->fq) ? NN_SOCKBASE_EVENT_IN : 0) | (nn_lb_can_send (&xreq->lb) ? NN_SOCKBASE_EVENT_OUT : 0); } int nn_xreq_send (struct nn_sockbase *self, struct nn_msg *msg) { return nn_xreq_send_to (self, msg, NULL); } int nn_xreq_send_to (struct nn_sockbase *self, struct nn_msg *msg, struct nn_pipe **to) { int rc; /* If request cannot be sent due to the pushback, drop it silenly. */ rc = nn_lb_send (&nn_cont (self, struct nn_xreq, sockbase)->lb, msg, to); if (nn_slow (rc == -EAGAIN)) return -EAGAIN; errnum_assert (rc >= 0, -rc); return 0; } int nn_xreq_recv (struct nn_sockbase *self, struct nn_msg *msg) { int rc; rc = nn_fq_recv (&nn_cont (self, struct nn_xreq, sockbase)->fq, msg, NULL); if (rc == -EAGAIN) return -EAGAIN; errnum_assert (rc >= 0, -rc); if (!(rc & NN_PIPE_PARSED)) { /* Ignore malformed replies. */ if (nn_slow (nn_chunkref_size (&msg->body) < sizeof (uint32_t))) { nn_msg_term (msg); return -EAGAIN; } /* Split the message into the header and the body. */ nn_assert (nn_chunkref_size (&msg->sphdr) == 0); nn_chunkref_term (&msg->sphdr); nn_chunkref_init (&msg->sphdr, sizeof (uint32_t)); memcpy (nn_chunkref_data (&msg->sphdr), nn_chunkref_data (&msg->body), sizeof (uint32_t)); nn_chunkref_trim (&msg->body, sizeof (uint32_t)); } return 0; } int nn_xreq_setopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED const void *optval, NN_UNUSED size_t optvallen) { return -ENOPROTOOPT; } int nn_xreq_getopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED void *optval, NN_UNUSED size_t *optvallen) { return -ENOPROTOOPT; } static int nn_xreq_create (void *hint, struct nn_sockbase **sockbase) { struct nn_xreq *self; self = nn_alloc (sizeof (struct nn_xreq), "socket (xreq)"); alloc_assert (self); nn_xreq_init (self, &nn_xreq_sockbase_vfptr, hint); *sockbase = &self->sockbase; return 0; } int nn_xreq_ispeer (int socktype) { return socktype == NN_REP ? 1 : 0; } static struct nn_socktype nn_xreq_socktype_struct = { AF_SP_RAW, NN_REQ, 0, nn_xreq_create, nn_xreq_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_xreq_socktype = &nn_xreq_socktype_struct; nanomsg-0.8-beta/src/protocols/survey/0000775000175000017500000000000012623652617021022 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/protocols/survey/respondent.h0000664000175000017500000000243312623652600023346 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_RESPONDENT_INCLUDED #define NN_RESPONDENT_INCLUDED #include "../../protocol.h" extern struct nn_socktype *nn_respondent_socktype; #endif nanomsg-0.8-beta/src/protocols/survey/respondent.c0000664000175000017500000001356412623652600023350 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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 "respondent.h" #include "xrespondent.h" #include "../../nn.h" #include "../../survey.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/alloc.h" #include "../../utils/wire.h" #include "../../utils/list.h" #include "../../utils/int.h" #include #define NN_RESPONDENT_INPROGRESS 1 struct nn_respondent { struct nn_xrespondent xrespondent; uint32_t flags; struct nn_chunkref backtrace; }; /* Private functions. */ static void nn_respondent_init (struct nn_respondent *self, const struct nn_sockbase_vfptr *vfptr, void *hint); static void nn_respondent_term (struct nn_respondent *self); /* Implementation of nn_sockbase's virtual functions. */ static void nn_respondent_destroy (struct nn_sockbase *self); static int nn_respondent_events (struct nn_sockbase *self); static int nn_respondent_send (struct nn_sockbase *self, struct nn_msg *msg); static int nn_respondent_recv (struct nn_sockbase *self, struct nn_msg *msg); static const struct nn_sockbase_vfptr nn_respondent_sockbase_vfptr = { NULL, nn_respondent_destroy, nn_xrespondent_add, nn_xrespondent_rm, nn_xrespondent_in, nn_xrespondent_out, nn_respondent_events, nn_respondent_send, nn_respondent_recv, nn_xrespondent_setopt, nn_xrespondent_getopt }; static void nn_respondent_init (struct nn_respondent *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_xrespondent_init (&self->xrespondent, vfptr, hint); self->flags = 0; } static void nn_respondent_term (struct nn_respondent *self) { if (self->flags & NN_RESPONDENT_INPROGRESS) nn_chunkref_term (&self->backtrace); nn_xrespondent_term (&self->xrespondent); } void nn_respondent_destroy (struct nn_sockbase *self) { struct nn_respondent *respondent; respondent = nn_cont (self, struct nn_respondent, xrespondent.sockbase); nn_respondent_term (respondent); nn_free (respondent); } static int nn_respondent_events (struct nn_sockbase *self) { int events; struct nn_respondent *respondent; respondent = nn_cont (self, struct nn_respondent, xrespondent.sockbase); events = nn_xrespondent_events (&respondent->xrespondent.sockbase); if (!(respondent->flags & NN_RESPONDENT_INPROGRESS)) events &= ~NN_SOCKBASE_EVENT_OUT; return events; } static int nn_respondent_send (struct nn_sockbase *self, struct nn_msg *msg) { int rc; struct nn_respondent *respondent; respondent = nn_cont (self, struct nn_respondent, xrespondent.sockbase); /* If there's no survey going on, report EFSM error. */ if (nn_slow (!(respondent->flags & NN_RESPONDENT_INPROGRESS))) return -EFSM; /* Tag the message with survey ID. */ nn_assert (nn_chunkref_size (&msg->sphdr) == 0); nn_chunkref_term (&msg->sphdr); nn_chunkref_mv (&msg->sphdr, &respondent->backtrace); /* Remember that no survey is being processed. */ respondent->flags &= ~NN_RESPONDENT_INPROGRESS; /* Try to send the message. If it cannot be sent due to pushback, drop it silently. */ rc = nn_xrespondent_send (&respondent->xrespondent.sockbase, msg); errnum_assert (rc == 0 || rc == -EAGAIN, -rc); return 0; } static int nn_respondent_recv (struct nn_sockbase *self, struct nn_msg *msg) { int rc; struct nn_respondent *respondent; respondent = nn_cont (self, struct nn_respondent, xrespondent.sockbase); /* Cancel current survey and clean up backtrace, if it exists. */ if (nn_slow (respondent->flags & NN_RESPONDENT_INPROGRESS)) { nn_chunkref_term (&respondent->backtrace); respondent->flags &= ~NN_RESPONDENT_INPROGRESS; } /* Get next survey. */ rc = nn_xrespondent_recv (&respondent->xrespondent.sockbase, msg); if (nn_slow (rc == -EAGAIN)) return -EAGAIN; errnum_assert (rc == 0, -rc); /* Store the backtrace. */ nn_chunkref_mv (&respondent->backtrace, &msg->sphdr); nn_chunkref_init (&msg->sphdr, 0); /* Remember that survey is being processed. */ respondent->flags |= NN_RESPONDENT_INPROGRESS; return 0; } static int nn_respondent_create (void *hint, struct nn_sockbase **sockbase) { struct nn_respondent *self; self = nn_alloc (sizeof (struct nn_respondent), "socket (respondent)"); alloc_assert (self); nn_respondent_init (self, &nn_respondent_sockbase_vfptr, hint); *sockbase = &self->xrespondent.sockbase; return 0; } static struct nn_socktype nn_respondent_socktype_struct = { AF_SP, NN_RESPONDENT, 0, nn_respondent_create, nn_xrespondent_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_respondent_socktype = &nn_respondent_socktype_struct; nanomsg-0.8-beta/src/protocols/survey/surveyor.h0000664000175000017500000000242612623652600023065 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_SURVEYOR_INCLUDED #define NN_SURVEYOR_INCLUDED #include "../../protocol.h" extern struct nn_socktype *nn_surveyor_socktype; #endif nanomsg-0.8-beta/src/protocols/survey/surveyor.c0000664000175000017500000004134612623652600023064 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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 "surveyor.h" #include "xsurveyor.h" #include "../../nn.h" #include "../../survey.h" #include "../../aio/fsm.h" #include "../../aio/timer.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/wire.h" #include "../../utils/alloc.h" #include "../../utils/random.h" #include "../../utils/list.h" #include "../../utils/int.h" #include "../../utils/attr.h" #include #define NN_SURVEYOR_DEFAULT_DEADLINE 1000 #define NN_SURVEYOR_STATE_IDLE 1 #define NN_SURVEYOR_STATE_PASSIVE 2 #define NN_SURVEYOR_STATE_ACTIVE 3 #define NN_SURVEYOR_STATE_CANCELLING 4 #define NN_SURVEYOR_STATE_STOPPING_TIMER 5 #define NN_SURVEYOR_STATE_STOPPING 6 #define NN_SURVEYOR_ACTION_START 1 #define NN_SURVEYOR_ACTION_CANCEL 2 #define NN_SURVEYOR_SRC_DEADLINE_TIMER 1 #define NN_SURVEYOR_TIMEDOUT 1 struct nn_surveyor { /* The underlying raw SP socket. */ struct nn_xsurveyor xsurveyor; /* The state machine. */ struct nn_fsm fsm; int state; /* Survey ID of the current survey. */ uint32_t surveyid; /* Timer for timing out the survey. */ struct nn_timer timer; /* When starting the survey, the message is temporarily stored here. */ struct nn_msg tosend; /* Protocol-specific socket options. */ int deadline; /* Flag if surveyor has timed out */ int timedout; }; /* Private functions. */ static void nn_surveyor_init (struct nn_surveyor *self, const struct nn_sockbase_vfptr *vfptr, void *hint); static void nn_surveyor_term (struct nn_surveyor *self); static void nn_surveyor_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_surveyor_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static int nn_surveyor_inprogress (struct nn_surveyor *self); static void nn_surveyor_resend (struct nn_surveyor *self); /* Implementation of nn_sockbase's virtual functions. */ static void nn_surveyor_stop (struct nn_sockbase *self); static void nn_surveyor_destroy (struct nn_sockbase *self); static int nn_surveyor_events (struct nn_sockbase *self); static int nn_surveyor_send (struct nn_sockbase *self, struct nn_msg *msg); static int nn_surveyor_recv (struct nn_sockbase *self, struct nn_msg *msg); static int nn_surveyor_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen); static int nn_surveyor_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen); static const struct nn_sockbase_vfptr nn_surveyor_sockbase_vfptr = { nn_surveyor_stop, nn_surveyor_destroy, nn_xsurveyor_add, nn_xsurveyor_rm, nn_xsurveyor_in, nn_xsurveyor_out, nn_surveyor_events, nn_surveyor_send, nn_surveyor_recv, nn_surveyor_setopt, nn_surveyor_getopt }; static void nn_surveyor_init (struct nn_surveyor *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_xsurveyor_init (&self->xsurveyor, vfptr, hint); nn_fsm_init_root (&self->fsm, nn_surveyor_handler, nn_surveyor_shutdown, nn_sockbase_getctx (&self->xsurveyor.sockbase)); self->state = NN_SURVEYOR_STATE_IDLE; /* Start assigning survey IDs beginning with a random number. This way there should be no key clashes even if the executable is re-started. */ nn_random_generate (&self->surveyid, sizeof (self->surveyid)); nn_timer_init (&self->timer, NN_SURVEYOR_SRC_DEADLINE_TIMER, &self->fsm); nn_msg_init (&self->tosend, 0); self->deadline = NN_SURVEYOR_DEFAULT_DEADLINE; self->timedout = 0; /* Start the state machine. */ nn_fsm_start (&self->fsm); } static void nn_surveyor_term (struct nn_surveyor *self) { nn_msg_term (&self->tosend); nn_timer_term (&self->timer); nn_fsm_term (&self->fsm); nn_xsurveyor_term (&self->xsurveyor); } void nn_surveyor_stop (struct nn_sockbase *self) { struct nn_surveyor *surveyor; surveyor = nn_cont (self, struct nn_surveyor, xsurveyor.sockbase); nn_fsm_stop (&surveyor->fsm); } void nn_surveyor_destroy (struct nn_sockbase *self) { struct nn_surveyor *surveyor; surveyor = nn_cont (self, struct nn_surveyor, xsurveyor.sockbase); nn_surveyor_term (surveyor); nn_free (surveyor); } static int nn_surveyor_inprogress (struct nn_surveyor *self) { /* Return 1 if there's a survey going on. 0 otherwise. */ return self->state == NN_SURVEYOR_STATE_IDLE || self->state == NN_SURVEYOR_STATE_PASSIVE || self->state == NN_SURVEYOR_STATE_STOPPING ? 0 : 1; } static int nn_surveyor_events (struct nn_sockbase *self) { int rc; struct nn_surveyor *surveyor; surveyor = nn_cont (self, struct nn_surveyor, xsurveyor.sockbase); /* Determine the actual readability/writability of the socket. */ rc = nn_xsurveyor_events (&surveyor->xsurveyor.sockbase); /* If there's no survey going on we'll signal IN to interrupt polling when the survey expires. nn_recv() will return -EFSM afterwards. */ if (!nn_surveyor_inprogress (surveyor)) rc |= NN_SOCKBASE_EVENT_IN; return rc; } static int nn_surveyor_send (struct nn_sockbase *self, struct nn_msg *msg) { struct nn_surveyor *surveyor; surveyor = nn_cont (self, struct nn_surveyor, xsurveyor.sockbase); /* Generate new survey ID. */ ++surveyor->surveyid; surveyor->surveyid |= 0x80000000; /* Tag the survey body with survey ID. */ nn_assert (nn_chunkref_size (&msg->sphdr) == 0); nn_chunkref_term (&msg->sphdr); nn_chunkref_init (&msg->sphdr, 4); nn_putl (nn_chunkref_data (&msg->sphdr), surveyor->surveyid); /* Store the survey, so that it can be sent later on. */ nn_msg_term (&surveyor->tosend); nn_msg_mv (&surveyor->tosend, msg); nn_msg_init (msg, 0); /* Cancel any ongoing survey, if any. */ if (nn_slow (nn_surveyor_inprogress (surveyor))) { /* First check whether the survey can be sent at all. */ if (!(nn_xsurveyor_events (&surveyor->xsurveyor.sockbase) & NN_SOCKBASE_EVENT_OUT)) return -EAGAIN; /* Cancel the current survey. */ nn_fsm_action (&surveyor->fsm, NN_SURVEYOR_ACTION_CANCEL); return 0; } /* Notify the state machine that the survey was started. */ nn_fsm_action (&surveyor->fsm, NN_SURVEYOR_ACTION_START); return 0; } static int nn_surveyor_recv (struct nn_sockbase *self, struct nn_msg *msg) { int rc; struct nn_surveyor *surveyor; uint32_t surveyid; surveyor = nn_cont (self, struct nn_surveyor, xsurveyor.sockbase); /* If no survey is going on return EFSM error. */ if (nn_slow (!nn_surveyor_inprogress (surveyor))) { if (surveyor->timedout == NN_SURVEYOR_TIMEDOUT) { surveyor->timedout = 0; return -ETIMEDOUT; } else return -EFSM; } while (1) { /* Get next response. */ rc = nn_xsurveyor_recv (&surveyor->xsurveyor.sockbase, msg); if (nn_slow (rc == -EAGAIN)) return -EAGAIN; errnum_assert (rc == 0, -rc); /* Get the survey ID. Ignore any stale responses. */ /* TODO: This should be done asynchronously! */ if (nn_slow (nn_chunkref_size (&msg->sphdr) != sizeof (uint32_t))) continue; surveyid = nn_getl (nn_chunkref_data (&msg->sphdr)); if (nn_slow (surveyid != surveyor->surveyid)) continue; /* Discard the header and return the message to the user. */ nn_chunkref_term (&msg->sphdr); nn_chunkref_init (&msg->sphdr, 0); break; } return 0; } static int nn_surveyor_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen) { struct nn_surveyor *surveyor; surveyor = nn_cont (self, struct nn_surveyor, xsurveyor.sockbase); if (level != NN_SURVEYOR) return -ENOPROTOOPT; if (option == NN_SURVEYOR_DEADLINE) { if (nn_slow (optvallen != sizeof (int))) return -EINVAL; surveyor->deadline = *(int*) optval; return 0; } return -ENOPROTOOPT; } static int nn_surveyor_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen) { struct nn_surveyor *surveyor; surveyor = nn_cont (self, struct nn_surveyor, xsurveyor.sockbase); if (level != NN_SURVEYOR) return -ENOPROTOOPT; if (option == NN_SURVEYOR_DEADLINE) { if (nn_slow (*optvallen < sizeof (int))) return -EINVAL; *(int*) optval = surveyor->deadline; *optvallen = sizeof (int); return 0; } return -ENOPROTOOPT; } static void nn_surveyor_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_surveyor *surveyor; surveyor = nn_cont (self, struct nn_surveyor, fsm); if (nn_slow (src== NN_FSM_ACTION && type == NN_FSM_STOP)) { nn_timer_stop (&surveyor->timer); surveyor->state = NN_SURVEYOR_STATE_STOPPING; } if (nn_slow (surveyor->state == NN_SURVEYOR_STATE_STOPPING)) { if (!nn_timer_isidle (&surveyor->timer)) return; surveyor->state = NN_SURVEYOR_STATE_IDLE; nn_fsm_stopped_noevent (&surveyor->fsm); nn_sockbase_stopped (&surveyor->xsurveyor.sockbase); return; } nn_fsm_bad_state(surveyor->state, src, type); } static void nn_surveyor_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_surveyor *surveyor; surveyor = nn_cont (self, struct nn_surveyor, fsm); switch (surveyor->state) { /******************************************************************************/ /* IDLE state. */ /* The socket was created recently. */ /******************************************************************************/ case NN_SURVEYOR_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: surveyor->state = NN_SURVEYOR_STATE_PASSIVE; return; default: nn_fsm_bad_action (surveyor->state, src, type); } default: nn_fsm_bad_source (surveyor->state, src, type); } /******************************************************************************/ /* PASSIVE state. */ /* There's no survey going on. */ /******************************************************************************/ case NN_SURVEYOR_STATE_PASSIVE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_SURVEYOR_ACTION_START: nn_surveyor_resend (surveyor); nn_timer_start (&surveyor->timer, surveyor->deadline); surveyor->state = NN_SURVEYOR_STATE_ACTIVE; return; default: nn_fsm_bad_action (surveyor->state, src, type); } default: nn_fsm_bad_source (surveyor->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /* Survey was sent, waiting for responses. */ /******************************************************************************/ case NN_SURVEYOR_STATE_ACTIVE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_SURVEYOR_ACTION_CANCEL: nn_timer_stop (&surveyor->timer); surveyor->state = NN_SURVEYOR_STATE_CANCELLING; return; default: nn_fsm_bad_action (surveyor->state, src, type); } case NN_SURVEYOR_SRC_DEADLINE_TIMER: switch (type) { case NN_TIMER_TIMEOUT: nn_timer_stop (&surveyor->timer); surveyor->state = NN_SURVEYOR_STATE_STOPPING_TIMER; surveyor->timedout = NN_SURVEYOR_TIMEDOUT; return; default: nn_fsm_bad_action (surveyor->state, src, type); } default: nn_fsm_bad_source (surveyor->state, src, type); } /******************************************************************************/ /* CANCELLING state. */ /* Survey was cancelled, but the old timer haven't stopped yet. The new */ /* survey thus haven't been sent and is stored in 'tosend'. */ /******************************************************************************/ case NN_SURVEYOR_STATE_CANCELLING: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_SURVEYOR_ACTION_CANCEL: return; default: nn_fsm_bad_action (surveyor->state, src, type); } case NN_SURVEYOR_SRC_DEADLINE_TIMER: switch (type) { case NN_TIMER_STOPPED: nn_surveyor_resend (surveyor); nn_timer_start (&surveyor->timer, surveyor->deadline); surveyor->state = NN_SURVEYOR_STATE_ACTIVE; return; default: nn_fsm_bad_action (surveyor->state, src, type); } default: nn_fsm_bad_source (surveyor->state, src, type); } /******************************************************************************/ /* STOPPING_TIMER state. */ /* Survey timeout expired. Now we are stopping the timer. */ /******************************************************************************/ case NN_SURVEYOR_STATE_STOPPING_TIMER: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_SURVEYOR_ACTION_CANCEL: surveyor->state = NN_SURVEYOR_STATE_CANCELLING; return; default: nn_fsm_bad_action (surveyor->state, src, type); } case NN_SURVEYOR_SRC_DEADLINE_TIMER: switch (type) { case NN_TIMER_STOPPED: surveyor->state = NN_SURVEYOR_STATE_PASSIVE; return; default: nn_fsm_bad_action (surveyor->state, src, type); } default: nn_fsm_bad_source (surveyor->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (surveyor->state, src, type); } } static void nn_surveyor_resend (struct nn_surveyor *self) { int rc; struct nn_msg msg; nn_msg_cp (&msg, &self->tosend); rc = nn_xsurveyor_send (&self->xsurveyor.sockbase, &msg); errnum_assert (rc == 0, -rc); } static int nn_surveyor_create (void *hint, struct nn_sockbase **sockbase) { struct nn_surveyor *self; self = nn_alloc (sizeof (struct nn_surveyor), "socket (surveyor)"); alloc_assert (self); nn_surveyor_init (self, &nn_surveyor_sockbase_vfptr, hint); *sockbase = &self->xsurveyor.sockbase; return 0; } static struct nn_socktype nn_surveyor_socktype_struct = { AF_SP, NN_SURVEYOR, 0, nn_surveyor_create, nn_xsurveyor_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_surveyor_socktype = &nn_surveyor_socktype_struct; nanomsg-0.8-beta/src/protocols/survey/xrespondent.h0000664000175000017500000000545512623652600023545 0ustar00travistravis00000000000000/* Copyright (c) 201-2013 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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. */ #ifndef NN_XRESPONDENT_INCLUDED #define NN_XRESPONDENT_INCLUDED #include "../../protocol.h" #include "../../utils/hash.h" #include "../../utils/int.h" #include "../utils/fq.h" extern struct nn_socktype *nn_xrespondent_socktype; #define NN_XRESPONDENT_OUT 1 struct nn_xrespondent_data { struct nn_pipe *pipe; struct nn_hash_item outitem; struct nn_fq_data initem; uint32_t flags; }; struct nn_xrespondent { struct nn_sockbase sockbase; /* Key to be assigned to the next added pipe. */ uint32_t next_key; /* Map of all registered pipes indexed by the peer ID. */ struct nn_hash outpipes; /* Fair-queuer to get surveys from. */ struct nn_fq inpipes; }; void nn_xrespondent_init (struct nn_xrespondent *self, const struct nn_sockbase_vfptr *vfptr, void *hint); void nn_xrespondent_term (struct nn_xrespondent *self); int nn_xrespondent_add (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xrespondent_rm (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xrespondent_in (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xrespondent_out (struct nn_sockbase *self, struct nn_pipe *pipe); int nn_xrespondent_events (struct nn_sockbase *self); int nn_xrespondent_send (struct nn_sockbase *self, struct nn_msg *msg); int nn_xrespondent_recv (struct nn_sockbase *self, struct nn_msg *msg); int nn_xrespondent_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen); int nn_xrespondent_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen); int nn_xrespondent_ispeer (int socktype); #endif nanomsg-0.8-beta/src/protocols/survey/xrespondent.c0000664000175000017500000002145512623652600023536 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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 "xrespondent.h" #include "../../nn.h" #include "../../survey.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/alloc.h" #include "../../utils/random.h" #include "../../utils/wire.h" #include "../../utils/list.h" #include "../../utils/attr.h" /* Private functions. */ static void nn_xrespondent_destroy (struct nn_sockbase *self); /* Implementation of nn_sockbase's virtual functions. */ static const struct nn_sockbase_vfptr nn_xrespondent_sockbase_vfptr = { NULL, nn_xrespondent_destroy, nn_xrespondent_add, nn_xrespondent_rm, nn_xrespondent_in, nn_xrespondent_out, nn_xrespondent_events, nn_xrespondent_send, nn_xrespondent_recv, nn_xrespondent_setopt, nn_xrespondent_getopt }; void nn_xrespondent_init (struct nn_xrespondent *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_sockbase_init (&self->sockbase, vfptr, hint); /* Pipes IDs should be random. See RFC for info. */ nn_random_generate (&self->next_key, sizeof (self->next_key)); nn_hash_init (&self->outpipes); nn_fq_init (&self->inpipes); } void nn_xrespondent_term (struct nn_xrespondent *self) { nn_fq_term (&self->inpipes); nn_hash_term (&self->outpipes); nn_sockbase_term (&self->sockbase); } static void nn_xrespondent_destroy (struct nn_sockbase *self) { struct nn_xrespondent *xrespondent; xrespondent = nn_cont (self, struct nn_xrespondent, sockbase); nn_xrespondent_term (xrespondent); nn_free (xrespondent); } int nn_xrespondent_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xrespondent *xrespondent; struct nn_xrespondent_data *data; int rcvprio; size_t sz; xrespondent = nn_cont (self, struct nn_xrespondent, sockbase); sz = sizeof (rcvprio); nn_pipe_getopt (pipe, NN_SOL_SOCKET, NN_RCVPRIO, &rcvprio, &sz); nn_assert (sz == sizeof (rcvprio)); nn_assert (rcvprio >= 1 && rcvprio <= 16); data = nn_alloc (sizeof (*data), "pipe data (xrespondent)"); alloc_assert (data); data->pipe = pipe; nn_hash_item_init (&data->outitem); data->flags = 0; nn_hash_insert (&xrespondent->outpipes, xrespondent->next_key & 0x7fffffff, &data->outitem); xrespondent->next_key++; nn_fq_add (&xrespondent->inpipes, &data->initem, pipe, rcvprio); nn_pipe_setdata (pipe, data); return 0; } void nn_xrespondent_rm (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xrespondent *xrespondent; struct nn_xrespondent_data *data; xrespondent = nn_cont (self, struct nn_xrespondent, sockbase); data = nn_pipe_getdata (pipe); nn_fq_rm (&xrespondent->inpipes, &data->initem); nn_hash_erase (&xrespondent->outpipes, &data->outitem); nn_hash_item_term (&data->outitem); nn_free (data); } void nn_xrespondent_in (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xrespondent *xrespondent; struct nn_xrespondent_data *data; xrespondent = nn_cont (self, struct nn_xrespondent, sockbase); data = nn_pipe_getdata (pipe); nn_fq_in (&xrespondent->inpipes, &data->initem); } void nn_xrespondent_out (NN_UNUSED struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xrespondent_data *data; data = nn_pipe_getdata (pipe); data->flags |= NN_XRESPONDENT_OUT; } int nn_xrespondent_events (struct nn_sockbase *self) { return (nn_fq_can_recv (&nn_cont (self, struct nn_xrespondent, sockbase)->inpipes) ? NN_SOCKBASE_EVENT_IN : 0) | NN_SOCKBASE_EVENT_OUT; } int nn_xrespondent_send (struct nn_sockbase *self, struct nn_msg *msg) { int rc; uint32_t key; struct nn_xrespondent *xrespondent; struct nn_xrespondent_data *data; xrespondent = nn_cont (self, struct nn_xrespondent, sockbase); /* We treat invalid peer ID as if the peer was non-existent. */ if (nn_slow (nn_chunkref_size (&msg->sphdr) < sizeof (uint32_t))) { nn_msg_term (msg); return 0; } /* Retrieve destination peer ID. Trim it from the header. */ key = nn_getl (nn_chunkref_data (&msg->sphdr)); nn_chunkref_trim (&msg->sphdr, 4); /* Find the appropriate pipe to send the message to. If there's none, or if it's not ready for sending, silently drop the message. */ data = nn_cont (nn_hash_get (&xrespondent->outpipes, key), struct nn_xrespondent_data, outitem); if (!data || !(data->flags & NN_XRESPONDENT_OUT)) { nn_msg_term (msg); return 0; } /* Send the message. */ rc = nn_pipe_send (data->pipe, msg); errnum_assert (rc >= 0, -rc); if (rc & NN_PIPE_RELEASE) data->flags &= ~NN_XRESPONDENT_OUT; return 0; } int nn_xrespondent_recv (struct nn_sockbase *self, struct nn_msg *msg) { int rc; struct nn_xrespondent *xrespondent; struct nn_pipe *pipe; int i; size_t sz; void *data; struct nn_chunkref ref; struct nn_xrespondent_data *pipedata; xrespondent = nn_cont (self, struct nn_xrespondent, sockbase); rc = nn_fq_recv (&xrespondent->inpipes, msg, &pipe); if (nn_slow (rc < 0)) return rc; /* Split the header (including survey ID) from the body, if needed. */ if (!(rc & NN_PIPE_PARSED)) { /* Determine the size of the message header. */ data = nn_chunkref_data (&msg->body); sz = nn_chunkref_size (&msg->body); i = 0; while (1) { /* Ignore the malformed surveys without the bottom of the stack. */ if (nn_slow ((i + 1) * sizeof (uint32_t) > sz)) { nn_msg_term (msg); return -EAGAIN; } /* If the bottom of the backtrace stack is reached, proceed. */ if (nn_getl ((uint8_t*)(((uint32_t*) data) + i)) & 0x80000000) break; ++i; } ++i; nn_assert (nn_chunkref_size (&msg->sphdr) == 0); nn_chunkref_term (&msg->sphdr); nn_chunkref_init (&msg->sphdr, i * sizeof (uint32_t)); memcpy (nn_chunkref_data (&msg->sphdr), data, i * sizeof (uint32_t)); nn_chunkref_trim (&msg->body, i * sizeof (uint32_t)); } /* Prepend the header by the pipe key. */ pipedata = nn_pipe_getdata (pipe); nn_chunkref_init (&ref, nn_chunkref_size (&msg->sphdr) + sizeof (uint32_t)); nn_putl (nn_chunkref_data (&ref), pipedata->outitem.key); memcpy (((uint8_t *) nn_chunkref_data (&ref)) + sizeof (uint32_t), nn_chunkref_data (&msg->sphdr), nn_chunkref_size (&msg->sphdr)); nn_chunkref_term (&msg->sphdr); nn_chunkref_mv (&msg->sphdr, &ref); return 0; } int nn_xrespondent_setopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED const void *optval, NN_UNUSED size_t optvallen) { return -ENOPROTOOPT; } int nn_xrespondent_getopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED void *optval, NN_UNUSED size_t *optvallen) { return -ENOPROTOOPT; } static int nn_xrespondent_create (void *hint, struct nn_sockbase **sockbase) { struct nn_xrespondent *self; self = nn_alloc (sizeof (struct nn_xrespondent), "socket (xrespondent)"); alloc_assert (self); nn_xrespondent_init (self, &nn_xrespondent_sockbase_vfptr, hint); *sockbase = &self->sockbase; return 0; } int nn_xrespondent_ispeer (int socktype) { return socktype == NN_SURVEYOR ? 1 : 0; } static struct nn_socktype nn_xrespondent_socktype_struct = { AF_SP_RAW, NN_RESPONDENT, 0, nn_xrespondent_create, nn_xrespondent_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_xrespondent_socktype = &nn_xrespondent_socktype_struct; nanomsg-0.8-beta/src/protocols/survey/xsurveyor.h0000664000175000017500000000510612623652600023253 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_XSURVEYOR_INCLUDED #define NN_XSURVEYOR_INCLUDED #include "../../protocol.h" #include "../utils/dist.h" #include "../utils/fq.h" extern struct nn_socktype *nn_xsurveyor_socktype; struct nn_xsurveyor_data { struct nn_pipe *pipe; struct nn_dist_data outitem; struct nn_fq_data initem; }; struct nn_xsurveyor { /* The generic socket base class. */ struct nn_sockbase sockbase; /* Distributor to send messages. */ struct nn_dist outpipes; /* Fair-queuer to receive messages. */ struct nn_fq inpipes; }; void nn_xsurveyor_init (struct nn_xsurveyor *self, const struct nn_sockbase_vfptr *vfptr, void *hint); void nn_xsurveyor_term (struct nn_xsurveyor *self); int nn_xsurveyor_add (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xsurveyor_rm (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xsurveyor_in (struct nn_sockbase *self, struct nn_pipe *pipe); void nn_xsurveyor_out (struct nn_sockbase *self, struct nn_pipe *pipe); int nn_xsurveyor_events (struct nn_sockbase *self); int nn_xsurveyor_send (struct nn_sockbase *self, struct nn_msg *msg); int nn_xsurveyor_recv (struct nn_sockbase *self, struct nn_msg *msg); int nn_xsurveyor_setopt (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen); int nn_xsurveyor_getopt (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen); int nn_xsurveyor_ispeer (int socktype); #endif nanomsg-0.8-beta/src/protocols/survey/xsurveyor.c0000664000175000017500000001504212623652600023246 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "xsurveyor.h" #include "../../nn.h" #include "../../survey.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/list.h" #include "../../utils/alloc.h" #include "../../utils/list.h" #include "../../utils/attr.h" #include /* Private functions. */ static void nn_xsurveyor_destroy (struct nn_sockbase *self); /* Implementation of nn_sockbase's virtual functions. */ static const struct nn_sockbase_vfptr nn_xsurveyor_sockbase_vfptr = { NULL, nn_xsurveyor_destroy, nn_xsurveyor_add, nn_xsurveyor_rm, nn_xsurveyor_in, nn_xsurveyor_out, nn_xsurveyor_events, nn_xsurveyor_send, nn_xsurveyor_recv, nn_xsurveyor_setopt, nn_xsurveyor_getopt }; void nn_xsurveyor_init (struct nn_xsurveyor *self, const struct nn_sockbase_vfptr *vfptr, void *hint) { nn_sockbase_init (&self->sockbase, vfptr, hint); nn_dist_init (&self->outpipes); nn_fq_init (&self->inpipes); } void nn_xsurveyor_term (struct nn_xsurveyor *self) { nn_fq_term (&self->inpipes); nn_dist_term (&self->outpipes); nn_sockbase_term (&self->sockbase); } static void nn_xsurveyor_destroy (struct nn_sockbase *self) { struct nn_xsurveyor *xsurveyor; xsurveyor = nn_cont (self, struct nn_xsurveyor, sockbase); nn_xsurveyor_term (xsurveyor); nn_free (xsurveyor); } int nn_xsurveyor_add (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xsurveyor *xsurveyor; struct nn_xsurveyor_data *data; int rcvprio; size_t sz; xsurveyor = nn_cont (self, struct nn_xsurveyor, sockbase); sz = sizeof (rcvprio); nn_pipe_getopt (pipe, NN_SOL_SOCKET, NN_RCVPRIO, &rcvprio, &sz); nn_assert (sz == sizeof (rcvprio)); nn_assert (rcvprio >= 1 && rcvprio <= 16); data = nn_alloc (sizeof (struct nn_xsurveyor_data), "pipe data (xsurveyor)"); alloc_assert (data); data->pipe = pipe; nn_fq_add (&xsurveyor->inpipes, &data->initem, pipe, rcvprio); nn_dist_add (&xsurveyor->outpipes, &data->outitem, pipe); nn_pipe_setdata (pipe, data); return 0; } void nn_xsurveyor_rm (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xsurveyor *xsurveyor; struct nn_xsurveyor_data *data; xsurveyor = nn_cont (self, struct nn_xsurveyor, sockbase); data = nn_pipe_getdata (pipe); nn_fq_rm (&xsurveyor->inpipes, &data->initem); nn_dist_rm (&xsurveyor->outpipes, &data->outitem); nn_free (data); } void nn_xsurveyor_in (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xsurveyor *xsurveyor; struct nn_xsurveyor_data *data; xsurveyor = nn_cont (self, struct nn_xsurveyor, sockbase); data = nn_pipe_getdata (pipe); nn_fq_in (&xsurveyor->inpipes, &data->initem); } void nn_xsurveyor_out (struct nn_sockbase *self, struct nn_pipe *pipe) { struct nn_xsurveyor *xsurveyor; struct nn_xsurveyor_data *data; xsurveyor = nn_cont (self, struct nn_xsurveyor, sockbase); data = nn_pipe_getdata (pipe); nn_dist_out (&xsurveyor->outpipes, &data->outitem); } int nn_xsurveyor_events (struct nn_sockbase *self) { struct nn_xsurveyor *xsurveyor; int events; xsurveyor = nn_cont (self, struct nn_xsurveyor, sockbase); events = NN_SOCKBASE_EVENT_OUT; if (nn_fq_can_recv (&xsurveyor->inpipes)) events |= NN_SOCKBASE_EVENT_IN; return events; } int nn_xsurveyor_send (struct nn_sockbase *self, struct nn_msg *msg) { return nn_dist_send ( &nn_cont (self, struct nn_xsurveyor, sockbase)->outpipes, msg, NULL); } int nn_xsurveyor_recv (struct nn_sockbase *self, struct nn_msg *msg) { int rc; struct nn_xsurveyor *xsurveyor; xsurveyor = nn_cont (self, struct nn_xsurveyor, sockbase); rc = nn_fq_recv (&xsurveyor->inpipes, msg, NULL); if (nn_slow (rc < 0)) return rc; /* Split the header from the body, if needed. */ if (!(rc & NN_PIPE_PARSED)) { if (nn_slow (nn_chunkref_size (&msg->body) < sizeof (uint32_t))) { nn_msg_term (msg); return -EAGAIN; } nn_assert (nn_chunkref_size (&msg->sphdr) == 0); nn_chunkref_term (&msg->sphdr); nn_chunkref_init (&msg->sphdr, sizeof (uint32_t)); memcpy (nn_chunkref_data (&msg->sphdr), nn_chunkref_data (&msg->body), sizeof (uint32_t)); nn_chunkref_trim (&msg->body, sizeof (uint32_t)); } return 0; } int nn_xsurveyor_setopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED const void *optval, NN_UNUSED size_t optvallen) { return -ENOPROTOOPT; } int nn_xsurveyor_getopt (NN_UNUSED struct nn_sockbase *self, NN_UNUSED int level, NN_UNUSED int option, NN_UNUSED void *optval, NN_UNUSED size_t *optvallen) { return -ENOPROTOOPT; } static int nn_xsurveyor_create (void *hint, struct nn_sockbase **sockbase) { struct nn_xsurveyor *self; self = nn_alloc (sizeof (struct nn_xsurveyor), "socket (xsurveyor)"); alloc_assert (self); nn_xsurveyor_init (self, &nn_xsurveyor_sockbase_vfptr, hint); *sockbase = &self->sockbase; return 0; } int nn_xsurveyor_ispeer (int socktype) { return socktype == NN_RESPONDENT ? 1 : 0; } static struct nn_socktype nn_xsurveyor_socktype_struct = { AF_SP_RAW, NN_SURVEYOR, 0, nn_xsurveyor_create, nn_xsurveyor_ispeer, NN_LIST_ITEM_INITIALIZER }; struct nn_socktype *nn_xsurveyor_socktype = &nn_xsurveyor_socktype_struct; nanomsg-0.8-beta/src/protocols/utils/0000775000175000017500000000000012623652617020625 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/protocols/utils/dist.h0000664000175000017500000000377712623652600021747 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_DIST_INCLUDED #define NN_DIST_INCLUDED #include "../../protocol.h" #include "../../utils/list.h" /* Distributor. Sends messages to all the pipes. */ struct nn_dist_data { struct nn_list_item item; struct nn_pipe *pipe; }; struct nn_dist { uint32_t count; struct nn_list pipes; }; void nn_dist_init (struct nn_dist *self); void nn_dist_term (struct nn_dist *self); void nn_dist_add (struct nn_dist *self, struct nn_dist_data *data, struct nn_pipe *pipe); void nn_dist_rm (struct nn_dist *self, struct nn_dist_data *data); void nn_dist_out (struct nn_dist *self, struct nn_dist_data *data); /* Sends the message to all the attached pipes except the one specified by 'exclude' parameter. If 'exclude' is NULL, message is sent to all attached pipes. */ int nn_dist_send (struct nn_dist *self, struct nn_msg *msg, struct nn_pipe *exclude); #endif nanomsg-0.8-beta/src/protocols/utils/dist.c0000664000175000017500000000645612623652600021737 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "dist.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/attr.h" #include void nn_dist_init (struct nn_dist *self) { self->count = 0; nn_list_init (&self->pipes); } void nn_dist_term (struct nn_dist *self) { nn_assert (self->count == 0); nn_list_term (&self->pipes); } void nn_dist_add (NN_UNUSED struct nn_dist *self, struct nn_dist_data *data, struct nn_pipe *pipe) { data->pipe = pipe; nn_list_item_init (&data->item); } void nn_dist_rm (struct nn_dist *self, struct nn_dist_data *data) { if (nn_list_item_isinlist (&data->item)) { --self->count; nn_list_erase (&self->pipes, &data->item); } nn_list_item_term (&data->item); } void nn_dist_out (struct nn_dist *self, struct nn_dist_data *data) { ++self->count; nn_list_insert (&self->pipes, &data->item, nn_list_end (&self->pipes)); } int nn_dist_send (struct nn_dist *self, struct nn_msg *msg, struct nn_pipe *exclude) { int rc; struct nn_list_item *it; struct nn_dist_data *data; struct nn_msg copy; /* TODO: We can optimise for the case when there's only one outbound pipe here. No message copying is needed in such case. */ /* In the specific case when there are no outbound pipes. There's nowhere to send the message to. Deallocate it. */ if (nn_slow (self->count) == 0) { nn_msg_term (msg); return 0; } /* Send the message to all the subscribers. */ nn_msg_bulkcopy_start (msg, self->count); it = nn_list_begin (&self->pipes); while (it != nn_list_end (&self->pipes)) { data = nn_cont (it, struct nn_dist_data, item); nn_msg_bulkcopy_cp (©, msg); if (nn_fast (data->pipe == exclude)) { nn_msg_term (©); } else { rc = nn_pipe_send (data->pipe, ©); errnum_assert (rc >= 0, -rc); if (rc & NN_PIPE_RELEASE) { --self->count; it = nn_list_erase (&self->pipes, it); continue; } } it = nn_list_next (&self->pipes, it); } nn_msg_term (msg); return 0; } nanomsg-0.8-beta/src/protocols/utils/excl.h0000664000175000017500000000446012623652600021725 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_EXCL_INCLUDED #define NN_EXCL_INCLUDED #include "../../protocol.h" #include /* This is an object to handle a single pipe. To be used by socket types that can work with precisely one connection, e.g. PAIR. */ struct nn_excl { /* The pipe being used at the moment. All other pipes will be rejected until this one terminates. NULL if there is no connected pipe. */ struct nn_pipe *pipe; /* Pipe ready for receiving. It's either equal to 'pipe' or NULL. */ struct nn_pipe *inpipe; /* Pipe ready for sending. It's either equal to 'pipe' or NULL. */ struct nn_pipe *outpipe; }; void nn_excl_init (struct nn_excl *self); void nn_excl_term (struct nn_excl *self); int nn_excl_add (struct nn_excl *self, struct nn_pipe *pipe); void nn_excl_rm (struct nn_excl *self, struct nn_pipe *pipe); void nn_excl_in (struct nn_excl *self, struct nn_pipe *pipe); void nn_excl_out (struct nn_excl *self, struct nn_pipe *pipe); int nn_excl_send (struct nn_excl *self, struct nn_msg *msg); int nn_excl_recv (struct nn_excl *self, struct nn_msg *msg); int nn_excl_can_send (struct nn_excl *self); int nn_excl_can_recv (struct nn_excl *self); #endif nanomsg-0.8-beta/src/protocols/utils/excl.c0000664000175000017500000000600612623652600021716 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "excl.h" #include "../../utils/fast.h" #include "../../utils/err.h" #include "../../utils/attr.h" void nn_excl_init (struct nn_excl *self) { self->pipe = NULL; self->inpipe = NULL; self->outpipe = NULL; } void nn_excl_term (struct nn_excl *self) { nn_assert (!self->pipe); nn_assert (!self->inpipe); nn_assert (!self->outpipe); } int nn_excl_add (struct nn_excl *self, struct nn_pipe *pipe) { /* If there's a connection being used, reject any new connection. */ if (self->pipe) return -EISCONN; /* Remember that this pipe is the active one. */ self->pipe = pipe; return 0; } void nn_excl_rm (struct nn_excl *self, NN_UNUSED struct nn_pipe *pipe) { nn_assert (self->pipe); self->pipe = NULL; self->inpipe = NULL; self->outpipe = NULL; } void nn_excl_in (struct nn_excl *self, struct nn_pipe *pipe) { nn_assert (!self->inpipe); nn_assert (pipe == self->pipe); self->inpipe = pipe; } void nn_excl_out (struct nn_excl *self, struct nn_pipe *pipe) { nn_assert (!self->outpipe); nn_assert (pipe == self->pipe); self->outpipe = pipe; } int nn_excl_send (struct nn_excl *self, struct nn_msg *msg) { int rc; if (nn_slow (!self->outpipe)) return -EAGAIN; rc = nn_pipe_send (self->outpipe, msg); errnum_assert (rc >= 0, -rc); if (rc & NN_PIPE_RELEASE) self->outpipe = NULL; return rc & ~NN_PIPE_RELEASE; } int nn_excl_recv (struct nn_excl *self, struct nn_msg *msg) { int rc; if (nn_slow (!self->inpipe)) return -EAGAIN; rc = nn_pipe_recv (self->inpipe, msg); errnum_assert (rc >= 0, -rc); if (rc & NN_PIPE_RELEASE) self->inpipe = NULL; return rc & ~NN_PIPE_RELEASE; } int nn_excl_can_send (struct nn_excl *self) { return self->outpipe ? 1 : 0; } int nn_excl_can_recv (struct nn_excl *self) { return self->inpipe ? 1 : 0; } nanomsg-0.8-beta/src/protocols/utils/fq.h0000664000175000017500000000353012623652600021375 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_FQ_INCLUDED #define NN_FQ_INCLUDED #include "../../protocol.h" #include "priolist.h" /* Fair-queuer. Retrieves messages from a set of pipes in round-robin manner. */ struct nn_fq_data { struct nn_priolist_data priodata; }; struct nn_fq { struct nn_priolist priolist; }; void nn_fq_init (struct nn_fq *self); void nn_fq_term (struct nn_fq *self); void nn_fq_add (struct nn_fq *self, struct nn_fq_data *data, struct nn_pipe *pipe, int priority); void nn_fq_rm (struct nn_fq *self, struct nn_fq_data *data); void nn_fq_in (struct nn_fq *self, struct nn_fq_data *data); int nn_fq_can_recv (struct nn_fq *self); int nn_fq_recv (struct nn_fq *self, struct nn_msg *msg, struct nn_pipe **pipe); #endif nanomsg-0.8-beta/src/protocols/utils/fq.c0000664000175000017500000000475212623652600021377 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "fq.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include void nn_fq_init (struct nn_fq *self) { nn_priolist_init (&self->priolist); } void nn_fq_term (struct nn_fq *self) { nn_priolist_term (&self->priolist); } void nn_fq_add (struct nn_fq *self, struct nn_fq_data *data, struct nn_pipe *pipe, int priority) { nn_priolist_add (&self->priolist, &data->priodata, pipe, priority); } void nn_fq_rm (struct nn_fq *self, struct nn_fq_data *data) { nn_priolist_rm (&self->priolist, &data->priodata); } void nn_fq_in (struct nn_fq *self, struct nn_fq_data *data) { nn_priolist_activate (&self->priolist, &data->priodata); } int nn_fq_can_recv (struct nn_fq *self) { return nn_priolist_is_active (&self->priolist); } int nn_fq_recv (struct nn_fq *self, struct nn_msg *msg, struct nn_pipe **pipe) { int rc; struct nn_pipe *p; /* Pipe is NULL only when there are no avialable pipes. */ p = nn_priolist_getpipe (&self->priolist); if (nn_slow (!p)) return -EAGAIN; /* Receive the messsage. */ rc = nn_pipe_recv (p, msg); errnum_assert (rc >= 0, -rc); /* Return the pipe data to the user, if required. */ if (pipe) *pipe = p; /* Move to the next pipe. */ nn_priolist_advance (&self->priolist, rc & NN_PIPE_RELEASE); return rc & ~NN_PIPE_RELEASE; } nanomsg-0.8-beta/src/protocols/utils/lb.h0000664000175000017500000000355712623652600021375 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_LB_INCLUDED #define NN_LB_INCLUDED #include "../../protocol.h" #include "priolist.h" /* A load balancer. Round-robins messages to a set of pipes. */ struct nn_lb_data { struct nn_priolist_data priodata; }; struct nn_lb { struct nn_priolist priolist; }; void nn_lb_init (struct nn_lb *self); void nn_lb_term (struct nn_lb *self); void nn_lb_add (struct nn_lb *self, struct nn_lb_data *data, struct nn_pipe *pipe, int priority); void nn_lb_rm (struct nn_lb *self, struct nn_lb_data *data); void nn_lb_out (struct nn_lb *self, struct nn_lb_data *data); int nn_lb_can_send (struct nn_lb *self); int nn_lb_get_priority (struct nn_lb *self); int nn_lb_send (struct nn_lb *self, struct nn_msg *msg, struct nn_pipe **to); #endif nanomsg-0.8-beta/src/protocols/utils/lb.c0000664000175000017500000000504712623652600021364 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "lb.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include void nn_lb_init (struct nn_lb *self) { nn_priolist_init (&self->priolist); } void nn_lb_term (struct nn_lb *self) { nn_priolist_term (&self->priolist); } void nn_lb_add (struct nn_lb *self, struct nn_lb_data *data, struct nn_pipe *pipe, int priority) { nn_priolist_add (&self->priolist, &data->priodata, pipe, priority); } void nn_lb_rm (struct nn_lb *self, struct nn_lb_data *data) { nn_priolist_rm (&self->priolist, &data->priodata); } void nn_lb_out (struct nn_lb *self, struct nn_lb_data *data) { nn_priolist_activate (&self->priolist, &data->priodata); } int nn_lb_can_send (struct nn_lb *self) { return nn_priolist_is_active (&self->priolist); } int nn_lb_get_priority (struct nn_lb *self) { return nn_priolist_get_priority (&self->priolist); } int nn_lb_send (struct nn_lb *self, struct nn_msg *msg, struct nn_pipe **to) { int rc; struct nn_pipe *pipe; /* Pipe is NULL only when there are no avialable pipes. */ pipe = nn_priolist_getpipe (&self->priolist); if (nn_slow (!pipe)) return -EAGAIN; /* Send the messsage. */ rc = nn_pipe_send (pipe, msg); errnum_assert (rc >= 0, -rc); /* Move to the next pipe. */ nn_priolist_advance (&self->priolist, rc & NN_PIPE_RELEASE); if (to != NULL) *to = pipe; return rc & ~NN_PIPE_RELEASE; } nanomsg-0.8-beta/src/protocols/utils/priolist.h0000664000175000017500000000731712623652600022643 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_PRIOLIST_INCLUDED #define NN_PRIOLIST_INCLUDED #include "../../protocol.h" #include "../../utils/list.h" /* Prioritised list of pipes. */ #define NN_PRIOLIST_SLOTS 16 struct nn_priolist_data { /* The underlying pipe itself. */ struct nn_pipe *pipe; /* Priority the pipe is assigned. Using this value we can find the nn_priolist_slot object that owns this pipe. */ int priority; /* The structure is a member in nn_priolist_slot's 'pipes' list. */ struct nn_list_item item; }; struct nn_priolist_slot { /* The list of pipes on particular priority level. */ struct nn_list pipes; /* Pointer to the current pipe within the priority level. If there's no pipe available, the field is set to NULL. */ struct nn_priolist_data *current; }; struct nn_priolist { /* Each slot holds pipes for a particular priority level. */ struct nn_priolist_slot slots [NN_PRIOLIST_SLOTS]; /* The index of the slot holding the current pipe. It should be the highest-priority non-empty slot available. If there's no available pipe, this field is set to -1. */ int current; }; /* Initialise the list. */ void nn_priolist_init (struct nn_priolist *self); /* Terminate the list. The list must be empty before it's terminated. */ void nn_priolist_term (struct nn_priolist *self); /* Add a new pipe to the list with a particular priority level. The pipe is not active at this point. Use nn_priolist_activate to activate it. */ void nn_priolist_add (struct nn_priolist *self, struct nn_priolist_data *data, struct nn_pipe *pipe, int priority); /* Remove the pipe from the list. */ void nn_priolist_rm (struct nn_priolist *self, struct nn_priolist_data *data); /* Activates a non-active pipe. The pipe must be added to the list prior to calling this function. */ void nn_priolist_activate (struct nn_priolist *self, struct nn_priolist_data *data); /* Returns 1 if there's at least a single active pipe in the list, 0 otherwise. */ int nn_priolist_is_active (struct nn_priolist *self); /* Get the pointer to the current pipe. If there's no pipe in the list, NULL is returned. */ struct nn_pipe *nn_priolist_getpipe (struct nn_priolist *self); /* Moves to the next pipe in the list. If 'release' is set to 1, the current pipe is removed from the list. To re-insert it into the list use nn_priolist_activate function. */ void nn_priolist_advance (struct nn_priolist *self, int release); /* Returns current priority. Used for statistics only */ int nn_priolist_get_priority (struct nn_priolist *self); #endif nanomsg-0.8-beta/src/protocols/utils/priolist.c0000664000175000017500000001305412623652600022631 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "priolist.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/err.h" #include "../../utils/attr.h" #include void nn_priolist_init (struct nn_priolist *self) { int i; for (i = 0; i != NN_PRIOLIST_SLOTS; ++i) { nn_list_init (&self->slots [i].pipes); self->slots [i].current = NULL; } self->current = -1; } void nn_priolist_term (struct nn_priolist *self) { int i; for (i = 0; i != NN_PRIOLIST_SLOTS; ++i) nn_list_term (&self->slots [i].pipes); } void nn_priolist_add (NN_UNUSED struct nn_priolist *self, struct nn_priolist_data *data, struct nn_pipe *pipe, int priority) { data->pipe = pipe; data->priority = priority; nn_list_item_init (&data->item); } void nn_priolist_rm (struct nn_priolist *self, struct nn_priolist_data *data) { struct nn_priolist_slot *slot; struct nn_list_item *it; /* Non-active pipes don't need any special processing. */ if (!nn_list_item_isinlist (&data->item)) { nn_list_item_term (&data->item); return; } /* If the pipe being removed is not current, we can simply erase it from the list. */ slot = &self->slots [data->priority - 1]; if (slot->current != data) { nn_list_erase (&slot->pipes, &data->item); nn_list_item_term (&data->item); return; } /* Advance the current pointer (with wrap-over). */ it = nn_list_erase (&slot->pipes, &data->item); slot->current = nn_cont (it, struct nn_priolist_data, item); nn_list_item_term (&data->item); if (!slot->current) { it = nn_list_begin (&slot->pipes); slot->current = nn_cont (it, struct nn_priolist_data, item); } /* If we are not messing with the current slot, we are done. */ if (self->current != data->priority) return; /* Otherwise, the current slot may have become empty and we have switch to lower priority slots. */ while (nn_list_empty (&self->slots [self->current - 1].pipes)) { ++self->current; if (self->current > NN_PRIOLIST_SLOTS) { self->current = -1; return; } } } void nn_priolist_activate (struct nn_priolist *self, struct nn_priolist_data *data) { struct nn_priolist_slot *slot; slot = &self->slots [data->priority - 1]; /* If there are already some elements in this slot, current pipe is not going to change. */ if (!nn_list_empty (&slot->pipes)) { nn_list_insert (&slot->pipes, &data->item, nn_list_end (&slot->pipes)); return; } /* Add first pipe into the slot. If there are no pipes in priolist at all this slot becomes current. */ nn_list_insert (&slot->pipes, &data->item, nn_list_end (&slot->pipes)); slot->current = data; if (self->current == -1) { self->current = data->priority; return; } /* If the current priority is lower than the one of the newly activated pipe, this slot becomes current. */ if (self->current > data->priority) { self->current = data->priority; return; } /* Current doesn't change otherwise. */ } int nn_priolist_is_active (struct nn_priolist *self) { return self->current == -1 ? 0 : 1; } struct nn_pipe *nn_priolist_getpipe (struct nn_priolist *self) { if (nn_slow (self->current == -1)) return NULL; return self->slots [self->current - 1].current->pipe; } void nn_priolist_advance (struct nn_priolist *self, int release) { struct nn_priolist_slot *slot; struct nn_list_item *it; nn_assert (self->current > 0); slot = &self->slots [self->current - 1]; /* Move slot's current pointer to the next pipe. */ if (release) it = nn_list_erase (&slot->pipes, &slot->current->item); else it = nn_list_next (&slot->pipes, &slot->current->item); if (!it) it = nn_list_begin (&slot->pipes); slot->current = nn_cont (it, struct nn_priolist_data, item); /* If there are no more pipes in this slot, find a non-empty slot with lower priority. */ while (nn_list_empty (&slot->pipes)) { ++self->current; if (self->current > NN_PRIOLIST_SLOTS) { self->current = -1; return; } slot = &self->slots [self->current - 1]; } } int nn_priolist_get_priority (struct nn_priolist *self) { return self->current; } nanomsg-0.8-beta/src/transports/0000775000175000017500000000000012623652617017660 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/transports/inproc/0000775000175000017500000000000012623652617021152 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/transports/inproc/binproc.h0000664000175000017500000000321312623652600022746 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_BINPROC_INCLUDED #define NN_BINPROC_INCLUDED #include "ins.h" #include "../../transport.h" #include "../../aio/fsm.h" #include "../../utils/list.h" struct nn_cinproc; struct nn_binproc { /* The state machine. */ struct nn_fsm fsm; int state; /* This object is registered with nn_ins. */ struct nn_ins_item item; /* The list of inproc sessions owned by this object. */ struct nn_list sinprocs; }; int nn_binproc_create (void *hint, struct nn_epbase **epbase); #endif nanomsg-0.8-beta/src/transports/inproc/binproc.c0000664000175000017500000002025512623652600022746 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "binproc.h" #include "sinproc.h" #include "cinproc.h" #include "ins.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/alloc.h" #define NN_BINPROC_STATE_IDLE 1 #define NN_BINPROC_STATE_ACTIVE 2 #define NN_BINPROC_STATE_STOPPING 3 #define NN_BINPROC_SRC_SINPROC 1 /* Implementation of nn_epbase interface. */ static void nn_binproc_stop (struct nn_epbase *self); static void nn_binproc_destroy (struct nn_epbase *self); static const struct nn_epbase_vfptr nn_binproc_vfptr = { nn_binproc_stop, nn_binproc_destroy }; /* Private functions. */ static void nn_binproc_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_binproc_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_binproc_connect (struct nn_ins_item *self, struct nn_ins_item *peer); int nn_binproc_create (void *hint, struct nn_epbase **epbase) { int rc; struct nn_binproc *self; self = nn_alloc (sizeof (struct nn_binproc), "binproc"); alloc_assert (self); nn_ins_item_init (&self->item, &nn_binproc_vfptr, hint); nn_fsm_init_root (&self->fsm, nn_binproc_handler, nn_binproc_shutdown, nn_epbase_getctx (&self->item.epbase)); self->state = NN_BINPROC_STATE_IDLE; nn_list_init (&self->sinprocs); /* Start the state machine. */ nn_fsm_start (&self->fsm); /* Register the inproc endpoint into a global repository. */ rc = nn_ins_bind (&self->item, nn_binproc_connect); if (nn_slow (rc < 0)) { nn_list_term (&self->sinprocs); /* TODO: Now, this is ugly! We are getting the state machine into the idle state manually. How should it be done correctly? */ self->fsm.state = 1; nn_fsm_term (&self->fsm); nn_ins_item_term (&self->item); nn_free (self); return rc; } *epbase = &self->item.epbase; return 0; } static void nn_binproc_stop (struct nn_epbase *self) { struct nn_binproc *binproc; binproc = nn_cont (self, struct nn_binproc, item.epbase); nn_fsm_stop (&binproc->fsm); } static void nn_binproc_destroy (struct nn_epbase *self) { struct nn_binproc *binproc; binproc = nn_cont (self, struct nn_binproc, item.epbase); nn_list_term (&binproc->sinprocs); nn_fsm_term (&binproc->fsm); nn_ins_item_term (&binproc->item); nn_free (binproc); } static void nn_binproc_connect (struct nn_ins_item *self, struct nn_ins_item *peer) { struct nn_binproc *binproc; struct nn_cinproc *cinproc; struct nn_sinproc *sinproc; binproc = nn_cont (self, struct nn_binproc, item); cinproc = nn_cont (peer, struct nn_cinproc, item); nn_assert_state (binproc, NN_BINPROC_STATE_ACTIVE); sinproc = nn_alloc (sizeof (struct nn_sinproc), "sinproc"); alloc_assert (sinproc); nn_sinproc_init (sinproc, NN_BINPROC_SRC_SINPROC, &binproc->item.epbase, &binproc->fsm); nn_list_insert (&binproc->sinprocs, &sinproc->item, nn_list_end (&binproc->sinprocs)); nn_sinproc_connect (sinproc, &cinproc->fsm); nn_epbase_stat_increment (&binproc->item.epbase, NN_STAT_ACCEPTED_CONNECTIONS, 1); } static void nn_binproc_shutdown (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_binproc *binproc; struct nn_list_item *it; struct nn_sinproc *sinproc; binproc = nn_cont (self, struct nn_binproc, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { /* First, unregister the endpoint from the global repository of inproc endpoints. This way, new connections cannot be created anymore. */ nn_ins_unbind (&binproc->item); /* Stop the existing connections. */ for (it = nn_list_begin (&binproc->sinprocs); it != nn_list_end (&binproc->sinprocs); it = nn_list_next (&binproc->sinprocs, it)) { sinproc = nn_cont (it, struct nn_sinproc, item); nn_sinproc_stop (sinproc); } binproc->state = NN_BINPROC_STATE_STOPPING; goto finish; } if (nn_slow (binproc->state == NN_BINPROC_STATE_STOPPING)) { nn_assert (src == NN_BINPROC_SRC_SINPROC && type == NN_SINPROC_STOPPED); sinproc = (struct nn_sinproc*) srcptr; nn_list_erase (&binproc->sinprocs, &sinproc->item); nn_sinproc_term (sinproc); nn_free (sinproc); finish: if (!nn_list_empty (&binproc->sinprocs)) return; binproc->state = NN_BINPROC_STATE_IDLE; nn_fsm_stopped_noevent (&binproc->fsm); nn_epbase_stopped (&binproc->item.epbase); return; } nn_fsm_bad_state(binproc->state, src, type); } static void nn_binproc_handler (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_binproc *binproc; struct nn_sinproc *peer; struct nn_sinproc *sinproc; binproc = nn_cont (self, struct nn_binproc, fsm); switch (binproc->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_BINPROC_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: binproc->state = NN_BINPROC_STATE_ACTIVE; return; default: nn_fsm_bad_action (binproc->state, src, type); } default: nn_fsm_bad_source (binproc->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /******************************************************************************/ case NN_BINPROC_STATE_ACTIVE: switch (src) { case NN_SINPROC_SRC_PEER: switch (type) { case NN_SINPROC_CONNECT: peer = (struct nn_sinproc*) srcptr; sinproc = nn_alloc (sizeof (struct nn_sinproc), "sinproc"); alloc_assert (sinproc); nn_sinproc_init (sinproc, NN_BINPROC_SRC_SINPROC, &binproc->item.epbase, &binproc->fsm); nn_list_insert (&binproc->sinprocs, &sinproc->item, nn_list_end (&binproc->sinprocs)); nn_sinproc_accept (sinproc, peer); return; default: nn_fsm_bad_action (binproc->state, src, type); } case NN_BINPROC_SRC_SINPROC: return; default: nn_fsm_bad_source (binproc->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (binproc->state, src, type); } } nanomsg-0.8-beta/src/transports/inproc/cinproc.h0000664000175000017500000000313112623652600022746 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_CINPROC_INCLUDED #define NN_CINPROC_INCLUDED #include "ins.h" #include "sinproc.h" #include "../../transport.h" #include "../../aio/fsm.h" struct nn_cinproc { /* The state machine. */ struct nn_fsm fsm; int state; /* This object is registered with nn_ins. */ struct nn_ins_item item; /* The actual inproc session. */ struct nn_sinproc sinproc; }; int nn_cinproc_create (void *hint, struct nn_epbase **epbase); #endif nanomsg-0.8-beta/src/transports/inproc/cinproc.c0000664000175000017500000002076512623652600022755 0ustar00travistravis00000000000000 /* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "cinproc.h" #include "binproc.h" #include "ins.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/alloc.h" #include "../../utils/attr.h" #include #define NN_CINPROC_STATE_IDLE 1 #define NN_CINPROC_STATE_DISCONNECTED 2 #define NN_CINPROC_STATE_ACTIVE 3 #define NN_CINPROC_STATE_STOPPING 4 #define NN_CINPROC_ACTION_CONNECT 1 #define NN_CINPROC_SRC_SINPROC 1 /* Implementation of nn_epbase callback interface. */ static void nn_cinproc_stop (struct nn_epbase *self); static void nn_cinproc_destroy (struct nn_epbase *self); static const struct nn_epbase_vfptr nn_cinproc_vfptr = { nn_cinproc_stop, nn_cinproc_destroy }; /* Private functions. */ static void nn_cinproc_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_cinproc_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_cinproc_connect (struct nn_ins_item *self, struct nn_ins_item *peer); int nn_cinproc_create (void *hint, struct nn_epbase **epbase) { struct nn_cinproc *self; self = nn_alloc (sizeof (struct nn_cinproc), "cinproc"); alloc_assert (self); nn_ins_item_init (&self->item, &nn_cinproc_vfptr, hint); nn_fsm_init_root (&self->fsm, nn_cinproc_handler, nn_cinproc_shutdown, nn_epbase_getctx (&self->item.epbase)); self->state = NN_CINPROC_STATE_IDLE; nn_sinproc_init (&self->sinproc, NN_CINPROC_SRC_SINPROC, &self->item.epbase, &self->fsm); /* Start the state machine. */ nn_fsm_start (&self->fsm); /* Register the inproc endpoint into a global repository. */ nn_ins_connect (&self->item, nn_cinproc_connect); *epbase = &self->item.epbase; return 0; } static void nn_cinproc_stop (struct nn_epbase *self) { struct nn_cinproc *cinproc; cinproc = nn_cont (self, struct nn_cinproc, item.epbase); nn_fsm_stop (&cinproc->fsm); } static void nn_cinproc_destroy (struct nn_epbase *self) { struct nn_cinproc *cinproc; cinproc = nn_cont (self, struct nn_cinproc, item.epbase); nn_sinproc_term (&cinproc->sinproc); nn_fsm_term (&cinproc->fsm); nn_ins_item_term (&cinproc->item); nn_free (cinproc); } static void nn_cinproc_connect (struct nn_ins_item *self, struct nn_ins_item *peer) { struct nn_cinproc *cinproc; struct nn_binproc *binproc; cinproc = nn_cont (self, struct nn_cinproc, item); binproc = nn_cont (peer, struct nn_binproc, item); nn_assert_state (cinproc, NN_CINPROC_STATE_DISCONNECTED); nn_sinproc_connect (&cinproc->sinproc, &binproc->fsm); nn_fsm_action (&cinproc->fsm, NN_CINPROC_ACTION_CONNECT); } static void nn_cinproc_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_cinproc *cinproc; cinproc = nn_cont (self, struct nn_cinproc, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { /* First, unregister the endpoint from the global repository of inproc endpoints. This way, new connections cannot be created anymore. */ nn_ins_disconnect (&cinproc->item); /* Stop the existing connection. */ nn_sinproc_stop (&cinproc->sinproc); cinproc->state = NN_CINPROC_STATE_STOPPING; } if (nn_slow (cinproc->state == NN_CINPROC_STATE_STOPPING)) { if (!nn_sinproc_isidle (&cinproc->sinproc)) return; cinproc->state = NN_CINPROC_STATE_IDLE; nn_fsm_stopped_noevent (&cinproc->fsm); nn_epbase_stopped (&cinproc->item.epbase); return; } nn_fsm_bad_state(cinproc->state, src, type); } static void nn_cinproc_handler (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_cinproc *cinproc; struct nn_sinproc *sinproc; cinproc = nn_cont (self, struct nn_cinproc, fsm); switch (cinproc->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_CINPROC_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: cinproc->state = NN_CINPROC_STATE_DISCONNECTED; nn_epbase_stat_increment (&cinproc->item.epbase, NN_STAT_INPROGRESS_CONNECTIONS, 1); return; default: nn_fsm_bad_action (cinproc->state, src, type); } default: nn_fsm_bad_source (cinproc->state, src, type); } /******************************************************************************/ /* DISCONNECTED state. */ /******************************************************************************/ case NN_CINPROC_STATE_DISCONNECTED: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_CINPROC_ACTION_CONNECT: cinproc->state = NN_CINPROC_STATE_ACTIVE; nn_epbase_stat_increment (&cinproc->item.epbase, NN_STAT_INPROGRESS_CONNECTIONS, -1); nn_epbase_stat_increment (&cinproc->item.epbase, NN_STAT_ESTABLISHED_CONNECTIONS, 1); return; default: nn_fsm_bad_action (cinproc->state, src, type); } case NN_SINPROC_SRC_PEER: sinproc = (struct nn_sinproc*) srcptr; switch (type) { case NN_SINPROC_CONNECT: nn_sinproc_accept (&cinproc->sinproc, sinproc); cinproc->state = NN_CINPROC_STATE_ACTIVE; nn_epbase_stat_increment (&cinproc->item.epbase, NN_STAT_INPROGRESS_CONNECTIONS, -1); nn_epbase_stat_increment (&cinproc->item.epbase, NN_STAT_ESTABLISHED_CONNECTIONS, 1); return; default: nn_fsm_bad_action (cinproc->state, src, type); } default: nn_fsm_bad_source (cinproc->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /******************************************************************************/ case NN_CINPROC_STATE_ACTIVE: switch (src) { case NN_CINPROC_SRC_SINPROC: switch (type) { case NN_SINPROC_DISCONNECT: cinproc->state = NN_CINPROC_STATE_DISCONNECTED; nn_epbase_stat_increment (&cinproc->item.epbase, NN_STAT_INPROGRESS_CONNECTIONS, 1); nn_sinproc_init (&cinproc->sinproc, NN_CINPROC_SRC_SINPROC, &cinproc->item.epbase, &cinproc->fsm); return; default: nn_fsm_bad_action (cinproc->state, src, type); } default: nn_fsm_bad_source (cinproc->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (cinproc->state, src, type); } } nanomsg-0.8-beta/src/transports/inproc/inproc.h0000664000175000017500000000240312623652600022604 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef NN_INPROC_INCLUDED #define NN_INPROC_INCLUDED #include "../../transport.h" extern struct nn_transport *nn_inproc; #endif nanomsg-0.8-beta/src/transports/inproc/inproc.c0000664000175000017500000000421712623652600022604 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "inproc.h" #include "ins.h" #include "binproc.h" #include "cinproc.h" #include "../../inproc.h" #include /* nn_transport interface. */ static void nn_inproc_init (void); static void nn_inproc_term (void); static int nn_inproc_bind (void *hint, struct nn_epbase **epbase); static int nn_inproc_connect (void *hint, struct nn_epbase **epbase); static struct nn_transport nn_inproc_vfptr = { "inproc", NN_INPROC, nn_inproc_init, nn_inproc_term, nn_inproc_bind, nn_inproc_connect, NULL, NN_LIST_ITEM_INITIALIZER }; struct nn_transport *nn_inproc = &nn_inproc_vfptr; static void nn_inproc_init (void) { nn_ins_init (); } static void nn_inproc_term (void) { nn_ins_term (); } static int nn_inproc_bind (void *hint, struct nn_epbase **epbase) { return nn_binproc_create (hint, epbase); } static int nn_inproc_connect (void *hint, struct nn_epbase **epbase) { return nn_cinproc_create (hint, epbase); } nanomsg-0.8-beta/src/transports/inproc/ins.h0000664000175000017500000000425012623652600022105 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_INS_INCLUDED #define NN_INS_INCLUDED #include "../../transport.h" #include "../../utils/list.h" /* Inproc naming system. A global repository of inproc endpoints. */ struct nn_ins_item { /* Every ins_item is an endpoint. */ struct nn_epbase epbase; /* Every ins_item is either in the list of bound or connected endpoints. */ struct nn_list_item item; /* This is the local cache of the endpoint's protocol ID. This way we can check the value without actually locking the object. */ int protocol; }; void nn_ins_item_init (struct nn_ins_item *self, const struct nn_epbase_vfptr *vfptr, void *hint); void nn_ins_item_term (struct nn_ins_item *self); void nn_ins_init (void); void nn_ins_term (void); typedef void (*nn_ins_fn) (struct nn_ins_item *self, struct nn_ins_item *peer); int nn_ins_bind (struct nn_ins_item *item, nn_ins_fn fn); void nn_ins_connect (struct nn_ins_item *item, nn_ins_fn fn); void nn_ins_disconnect (struct nn_ins_item *item); void nn_ins_unbind (struct nn_ins_item *item); #endif nanomsg-0.8-beta/src/transports/inproc/ins.c0000664000175000017500000001263112623652600022102 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "ins.h" #include "../../utils/mutex.h" #include "../../utils/alloc.h" #include "../../utils/list.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/err.h" struct nn_ins { /* Synchronises access to this object. */ struct nn_mutex sync; /* List of all bound inproc endpoints. */ /* TODO: O(n) lookup, shouldn't we do better? Hash? */ struct nn_list bound; /* List of all connected inproc endpoints. */ /* TODO: O(n) lookup, shouldn't we do better? Hash? */ struct nn_list connected; }; /* Global instance of the nn_ins object. It contains the lists of all inproc endpoints in the current process. */ static struct nn_ins self; void nn_ins_item_init (struct nn_ins_item *self, const struct nn_epbase_vfptr *vfptr, void *hint) { size_t sz; nn_epbase_init (&self->epbase, vfptr, hint); nn_list_item_init (&self->item); sz = sizeof (self->protocol); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_PROTOCOL, &self->protocol, &sz); nn_assert (sz == sizeof (self->protocol)); } void nn_ins_item_term (struct nn_ins_item *self) { nn_list_item_term (&self->item); nn_epbase_term (&self->epbase); } void nn_ins_init (void) { nn_mutex_init (&self.sync); nn_list_init (&self.bound); nn_list_init (&self.connected); } void nn_ins_term (void) { nn_list_term (&self.connected); nn_list_term (&self.bound); nn_mutex_term (&self.sync); } int nn_ins_bind (struct nn_ins_item *item, nn_ins_fn fn) { struct nn_list_item *it; struct nn_ins_item *bitem; struct nn_ins_item *citem; nn_mutex_lock (&self.sync); /* Check whether the endpoint isn't already bound. */ /* TODO: This is an O(n) algorithm! */ for (it = nn_list_begin (&self.bound); it != nn_list_end (&self.bound); it = nn_list_next (&self.bound, it)) { bitem = nn_cont (it, struct nn_ins_item, item); if (strncmp (nn_epbase_getaddr (&item->epbase), nn_epbase_getaddr (&bitem->epbase), NN_SOCKADDR_MAX) == 0) { nn_mutex_unlock (&self.sync); return -EADDRINUSE; } } /* Insert the entry into the endpoint repository. */ nn_list_insert (&self.bound, &item->item, nn_list_end (&self.bound)); /* During this process new pipes may be created. */ for (it = nn_list_begin (&self.connected); it != nn_list_end (&self.connected); it = nn_list_next (&self.connected, it)) { citem = nn_cont (it, struct nn_ins_item, item); if (strncmp (nn_epbase_getaddr (&item->epbase), nn_epbase_getaddr (&citem->epbase), NN_SOCKADDR_MAX) == 0) { /* Check whether the two sockets are compatible. */ if (!nn_epbase_ispeer (&item->epbase, citem->protocol)) continue; fn (item, citem); } } nn_mutex_unlock (&self.sync); return 0; } void nn_ins_connect (struct nn_ins_item *item, nn_ins_fn fn) { struct nn_list_item *it; struct nn_ins_item *bitem; nn_mutex_lock (&self.sync); /* Insert the entry into the endpoint repository. */ nn_list_insert (&self.connected, &item->item, nn_list_end (&self.connected)); /* During this process a pipe may be created. */ for (it = nn_list_begin (&self.bound); it != nn_list_end (&self.bound); it = nn_list_next (&self.bound, it)) { bitem = nn_cont (it, struct nn_ins_item, item); if (strncmp (nn_epbase_getaddr (&item->epbase), nn_epbase_getaddr (&bitem->epbase), NN_SOCKADDR_MAX) == 0) { /* Check whether the two sockets are compatible. */ if (!nn_epbase_ispeer (&item->epbase, bitem->protocol)) break; /* Call back to cinproc to create actual connection. */ fn (item, bitem); break; } } nn_mutex_unlock (&self.sync); } void nn_ins_disconnect (struct nn_ins_item *item) { nn_mutex_lock (&self.sync); nn_list_erase (&self.connected, &item->item); nn_mutex_unlock (&self.sync); } void nn_ins_unbind (struct nn_ins_item *item) { nn_mutex_lock (&self.sync); nn_list_erase (&self.bound, &item->item); nn_mutex_unlock (&self.sync); } nanomsg-0.8-beta/src/transports/inproc/msgqueue.h0000664000175000017500000000572012623652600023152 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_MSGQUEUE_INCLUDED #define NN_MSGQUEUE_INCLUDED #include "../../utils/msg.h" #include /* This class is a simple uni-directional message queue. */ /* It's not 128 so that chunk including its footer fits into a memory page. */ #define NN_MSGQUEUE_GRANULARITY 126 struct nn_msgqueue_chunk { struct nn_msg msgs [NN_MSGQUEUE_GRANULARITY]; struct nn_msgqueue_chunk *next; }; struct nn_msgqueue { /* Pointer to the position where next message should be written into the message queue. */ struct { struct nn_msgqueue_chunk *chunk; int pos; } out; /* Pointer to the first unread message in the message queue. */ struct { struct nn_msgqueue_chunk *chunk; int pos; } in; /* Number of messages in the queue. */ size_t count; /* Amount of memory used by messages in the queue. */ size_t mem; /* Maximal queue size (in bytes). */ size_t maxmem; /* One empty chunk is always cached so that in case of steady stream of messages through the pipe there are no memory allocations. */ struct nn_msgqueue_chunk *cache; }; /* Initialise the message pipe. maxmem is the maximal queue size in bytes. */ void nn_msgqueue_init (struct nn_msgqueue *self, size_t maxmem); /* Terminate the message pipe. */ void nn_msgqueue_term (struct nn_msgqueue *self); /* Returns 1 if there are no messages in the queue, 0 otherwise. */ int nn_msgqueue_empty (struct nn_msgqueue *self); /* Writes a message to the pipe. -EAGAIN is returned if the message cannot be sent because the queue is full. */ int nn_msgqueue_send (struct nn_msgqueue *self, struct nn_msg *msg); /* Reads a message from the pipe. -EAGAIN is returned if there's no message to receive. */ int nn_msgqueue_recv (struct nn_msgqueue *self, struct nn_msg *msg); #endif nanomsg-0.8-beta/src/transports/inproc/msgqueue.c0000664000175000017500000001071012623652600023140 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "msgqueue.h" #include "../../utils/alloc.h" #include "../../utils/fast.h" #include "../../utils/err.h" #include void nn_msgqueue_init (struct nn_msgqueue *self, size_t maxmem) { struct nn_msgqueue_chunk *chunk; self->count = 0; self->mem = 0; self->maxmem = maxmem; chunk = nn_alloc (sizeof (struct nn_msgqueue_chunk), "msgqueue chunk"); alloc_assert (chunk); chunk->next = NULL; self->out.chunk = chunk; self->out.pos = 0; self->in.chunk = chunk; self->in.pos = 0; self->cache = NULL; } void nn_msgqueue_term (struct nn_msgqueue *self) { int rc; struct nn_msg msg; /* Deallocate messages in the pipe. */ while (1) { rc = nn_msgqueue_recv (self, &msg); if (rc == -EAGAIN) break; errnum_assert (rc >= 0, -rc); nn_msg_term (&msg); } /* There are no more messages in the pipe so there's at most one chunk in the queue. Deallocate it. */ nn_assert (self->in.chunk == self->out.chunk); nn_free (self->in.chunk); /* Deallocate the cached chunk, if any. */ if (self->cache) nn_free (self->cache); } int nn_msgqueue_empty (struct nn_msgqueue *self) { return self->count == 0 ? 1 : 0; } int nn_msgqueue_send (struct nn_msgqueue *self, struct nn_msg *msg) { size_t msgsz; /* By allowing one message of arbitrary size to be written to the queue, we allow even messages that exceed max buffer size to pass through. Beyond that we'll apply the buffer limit as specified by the user. */ msgsz = nn_chunkref_size (&msg->sphdr) + nn_chunkref_size (&msg->body); if (nn_slow (self->count > 0 && self->mem + msgsz >= self->maxmem)) return -EAGAIN; /* Adjust the statistics. */ ++self->count; self->mem += msgsz; /* Move the content of the message to the pipe. */ nn_msg_mv (&self->out.chunk->msgs [self->out.pos], msg); ++self->out.pos; /* If there's no space for a new message in the pipe, either re-use the cache chunk or allocate a new chunk if it does not exist. */ if (nn_slow (self->out.pos == NN_MSGQUEUE_GRANULARITY)) { if (nn_slow (!self->cache)) { self->cache = nn_alloc (sizeof (struct nn_msgqueue_chunk), "msgqueue chunk"); alloc_assert (self->cache); self->cache->next = NULL; } self->out.chunk->next = self->cache; self->out.chunk = self->cache; self->cache = NULL; self->out.pos = 0; } return 0; } int nn_msgqueue_recv (struct nn_msgqueue *self, struct nn_msg *msg) { struct nn_msgqueue_chunk *o; /* If there is no message in the queue. */ if (nn_slow (!self->count)) return -EAGAIN; /* Move the message from the pipe to the user. */ nn_msg_mv (msg, &self->in.chunk->msgs [self->in.pos]); /* Move to the next position. */ ++self->in.pos; if (nn_slow (self->in.pos == NN_MSGQUEUE_GRANULARITY)) { o = self->in.chunk; self->in.chunk = self->in.chunk->next; self->in.pos = 0; if (nn_fast (!self->cache)) self->cache = o; else nn_free (o); } /* Adjust the statistics. */ --self->count; self->mem -= (nn_chunkref_size (&msg->sphdr) + nn_chunkref_size (&msg->body)); return 0; } nanomsg-0.8-beta/src/transports/inproc/sinproc.h0000664000175000017500000000647312623652600023002 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_SINPROC_INCLUDED #define NN_SINPROC_INCLUDED #include "msgqueue.h" #include "../../transport.h" #include "../../aio/fsm.h" #include "../../utils/msg.h" #include "../../utils/list.h" #define NN_SINPROC_CONNECT 1 #define NN_SINPROC_READY 2 #define NN_SINPROC_ACCEPTED 3 #define NN_SINPROC_SENT 4 #define NN_SINPROC_RECEIVED 5 #define NN_SINPROC_DISCONNECT 6 #define NN_SINPROC_STOPPED 7 /* We use a random value here to prevent accidental clashes with the peer's internal source IDs. */ #define NN_SINPROC_SRC_PEER 27713 struct nn_sinproc { /* The state machine. */ struct nn_fsm fsm; int state; /* Any combination of the flags defined in the .c file. */ int flags; /* Pointer to the peer inproc session, if connected. NULL otherwise. */ struct nn_sinproc *peer; /* Pipe connecting this inproc connection to the nanomsg core. */ struct nn_pipebase pipebase; /* Inbound message queue. The messages contained are meant to be received by the user later on. */ struct nn_msgqueue msgqueue; /* This message is the one being sent from this session to the peer session. It holds the data only temporarily, until the peer moves it to its msgqueue. */ struct nn_msg msg; /* Outbound events. I.e. event sent by this sinproc to the peer sinproc. */ struct nn_fsm_event event_connect; /* Inbound events. I.e. events sent by the peer sinproc to this inproc. */ struct nn_fsm_event event_sent; struct nn_fsm_event event_received; struct nn_fsm_event event_disconnect; /* This member is used only if we are on the bound side. binproc object has a list of sinprocs it handles. */ struct nn_list_item item; }; void nn_sinproc_init (struct nn_sinproc *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner); void nn_sinproc_term (struct nn_sinproc *self); int nn_sinproc_isidle (struct nn_sinproc *self); /* Connect and accept are two different ways to start the state machine. */ void nn_sinproc_connect (struct nn_sinproc *self, struct nn_fsm *peer); void nn_sinproc_accept (struct nn_sinproc *self, struct nn_sinproc *peer); void nn_sinproc_stop (struct nn_sinproc *self); #endif nanomsg-0.8-beta/src/transports/inproc/sinproc.c0000664000175000017500000004104112623652600022763 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "sinproc.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/attr.h" #include #define NN_SINPROC_STATE_IDLE 1 #define NN_SINPROC_STATE_CONNECTING 2 #define NN_SINPROC_STATE_READY 3 #define NN_SINPROC_STATE_ACTIVE 4 #define NN_SINPROC_STATE_DISCONNECTED 5 #define NN_SINPROC_STATE_STOPPING_PEER 6 #define NN_SINPROC_STATE_STOPPING 7 #define NN_SINPROC_ACTION_READY 1 #define NN_SINPROC_ACTION_ACCEPTED 2 /* Set when SENT event was sent to the peer but RECEIVED haven't been passed back yet. */ #define NN_SINPROC_FLAG_SENDING 1 /* Set when SENT event was received, but the new message cannot be written to the queue yet, i.e. RECEIVED event haven't been returned to the peer yet. */ #define NN_SINPROC_FLAG_RECEIVING 2 /* Private functions. */ static void nn_sinproc_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_sinproc_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static int nn_sinproc_send (struct nn_pipebase *self, struct nn_msg *msg); static int nn_sinproc_recv (struct nn_pipebase *self, struct nn_msg *msg); const struct nn_pipebase_vfptr nn_sinproc_pipebase_vfptr = { nn_sinproc_send, nn_sinproc_recv }; void nn_sinproc_init (struct nn_sinproc *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner) { int rcvbuf; size_t sz; nn_fsm_init (&self->fsm, nn_sinproc_handler, nn_sinproc_shutdown, src, self, owner); self->state = NN_SINPROC_STATE_IDLE; self->flags = 0; self->peer = NULL; nn_pipebase_init (&self->pipebase, &nn_sinproc_pipebase_vfptr, epbase); sz = sizeof (rcvbuf); nn_epbase_getopt (epbase, NN_SOL_SOCKET, NN_RCVBUF, &rcvbuf, &sz); nn_assert (sz == sizeof (rcvbuf)); nn_msgqueue_init (&self->msgqueue, rcvbuf); nn_msg_init (&self->msg, 0); nn_fsm_event_init (&self->event_connect); nn_fsm_event_init (&self->event_sent); nn_fsm_event_init (&self->event_received); nn_fsm_event_init (&self->event_disconnect); nn_list_item_init (&self->item); } void nn_sinproc_term (struct nn_sinproc *self) { nn_list_item_term (&self->item); nn_fsm_event_term (&self->event_disconnect); nn_fsm_event_term (&self->event_received); nn_fsm_event_term (&self->event_sent); nn_fsm_event_term (&self->event_connect); nn_msg_term (&self->msg); nn_msgqueue_term (&self->msgqueue); nn_pipebase_term (&self->pipebase); nn_fsm_term (&self->fsm); } int nn_sinproc_isidle (struct nn_sinproc *self) { return nn_fsm_isidle (&self->fsm); } void nn_sinproc_connect (struct nn_sinproc *self, struct nn_fsm *peer) { nn_fsm_start (&self->fsm); /* Start the connecting handshake with the peer. */ nn_fsm_raiseto (&self->fsm, peer, &self->event_connect, NN_SINPROC_SRC_PEER, NN_SINPROC_CONNECT, self); } void nn_sinproc_accept (struct nn_sinproc *self, struct nn_sinproc *peer) { nn_assert (!self->peer); self->peer = peer; /* Start the connecting handshake with the peer. */ nn_fsm_raiseto (&self->fsm, &peer->fsm, &self->event_connect, NN_SINPROC_SRC_PEER, NN_SINPROC_READY, self); /* Notify the state machine. */ nn_fsm_start (&self->fsm); nn_fsm_action (&self->fsm, NN_SINPROC_ACTION_READY); } void nn_sinproc_stop (struct nn_sinproc *self) { nn_fsm_stop (&self->fsm); } static int nn_sinproc_send (struct nn_pipebase *self, struct nn_msg *msg) { struct nn_sinproc *sinproc; sinproc = nn_cont (self, struct nn_sinproc, pipebase); /* If the peer have already closed the connection, we cannot send anymore. */ if (sinproc->state == NN_SINPROC_STATE_DISCONNECTED) return -ECONNRESET; /* Sanity checks. */ nn_assert_state (sinproc, NN_SINPROC_STATE_ACTIVE); nn_assert (!(sinproc->flags & NN_SINPROC_FLAG_SENDING)); /* Expose the message to the peer. */ nn_msg_term (&sinproc->msg); nn_msg_mv (&sinproc->msg, msg); /* Notify the peer that there's a message to get. */ sinproc->flags |= NN_SINPROC_FLAG_SENDING; nn_fsm_raiseto (&sinproc->fsm, &sinproc->peer->fsm, &sinproc->peer->event_sent, NN_SINPROC_SRC_PEER, NN_SINPROC_SENT, sinproc); return 0; } static int nn_sinproc_recv (struct nn_pipebase *self, struct nn_msg *msg) { int rc; struct nn_sinproc *sinproc; sinproc = nn_cont (self, struct nn_sinproc, pipebase); /* Sanity check. */ nn_assert (sinproc->state == NN_SINPROC_STATE_ACTIVE || sinproc->state == NN_SINPROC_STATE_DISCONNECTED); /* Move the message to the caller. */ rc = nn_msgqueue_recv (&sinproc->msgqueue, msg); errnum_assert (rc == 0, -rc); /* If there was a message from peer lingering because of the exceeded buffer limit, try to enqueue it once again. */ if (sinproc->state != NN_SINPROC_STATE_DISCONNECTED) { if (nn_slow (sinproc->flags & NN_SINPROC_FLAG_RECEIVING)) { rc = nn_msgqueue_send (&sinproc->msgqueue, &sinproc->peer->msg); nn_assert (rc == 0 || rc == -EAGAIN); if (rc == 0) { errnum_assert (rc == 0, -rc); nn_msg_init (&sinproc->peer->msg, 0); nn_fsm_raiseto (&sinproc->fsm, &sinproc->peer->fsm, &sinproc->peer->event_received, NN_SINPROC_SRC_PEER, NN_SINPROC_RECEIVED, sinproc); sinproc->flags &= ~NN_SINPROC_FLAG_RECEIVING; } } } if (!nn_msgqueue_empty (&sinproc->msgqueue)) nn_pipebase_received (&sinproc->pipebase); return NN_PIPEBASE_PARSED; } static void nn_sinproc_shutdown_events (struct nn_sinproc *self, int src, int type, NN_UNUSED void *srcptr) { /* ******************************* */ /* Any-state events */ /* ******************************* */ switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_STOP: if (self->state != NN_SINPROC_STATE_IDLE && self->state != NN_SINPROC_STATE_DISCONNECTED) { nn_pipebase_stop (&self->pipebase); nn_assert (self->fsm.state == 2 || self->fsm.state == 3); nn_fsm_raiseto (&self->fsm, &self->peer->fsm, &self->peer->event_disconnect, NN_SINPROC_SRC_PEER, NN_SINPROC_DISCONNECT, self); self->state = NN_SINPROC_STATE_STOPPING_PEER; } else { self->state = NN_SINPROC_STATE_STOPPING; } return; } case NN_SINPROC_SRC_PEER: switch (type) { case NN_SINPROC_RECEIVED: return; } } /* ******************************* */ /* Regular events */ /* ******************************* */ switch (self->state) { case NN_SINPROC_STATE_STOPPING_PEER: switch (src) { case NN_SINPROC_SRC_PEER: switch (type) { case NN_SINPROC_DISCONNECT: self->state = NN_SINPROC_STATE_STOPPING; return; default: nn_fsm_bad_action (self->state, src, type); } default: nn_fsm_bad_source (self->state, src, type); } default: nn_fsm_bad_state (self->state, src, type); } nn_fsm_bad_action (self->state, src, type); } static void nn_sinproc_shutdown (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_sinproc *sinproc; sinproc = nn_cont (self, struct nn_sinproc, fsm); nn_assert (sinproc->fsm.state == 3); nn_sinproc_shutdown_events (sinproc, src, type, srcptr); /* *************** */ /* States to check */ /* *************** */ /* Have we got notification that peer is stopped */ if (nn_slow (sinproc->state != NN_SINPROC_STATE_STOPPING)) { return; } /* Are all events processed? We can't cancel them unfortunately */ if (nn_fsm_event_active (&sinproc->event_received) || nn_fsm_event_active (&sinproc->event_disconnect)) { return; } /* These events are deemed to be impossible here */ nn_assert (!nn_fsm_event_active (&sinproc->event_connect)); nn_assert (!nn_fsm_event_active (&sinproc->event_sent)); /* ********************************************** */ /* All checks are successful. Just stop right now */ /* ********************************************** */ nn_fsm_stopped (&sinproc->fsm, NN_SINPROC_STOPPED); return; } static void nn_sinproc_handler (struct nn_fsm *self, int src, int type, void *srcptr) { int rc; struct nn_sinproc *sinproc; int empty; sinproc = nn_cont (self, struct nn_sinproc, fsm); switch (sinproc->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_SINPROC_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: sinproc->state = NN_SINPROC_STATE_CONNECTING; return; default: nn_fsm_bad_action (sinproc->state, src, type); } default: nn_fsm_bad_source (sinproc->state, src, type); } /******************************************************************************/ /* CONNECTING state. */ /* CONNECT request was sent to the peer. Now we are waiting for the */ /* acknowledgement. */ /******************************************************************************/ case NN_SINPROC_STATE_CONNECTING: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_SINPROC_ACTION_READY: sinproc->state = NN_SINPROC_STATE_READY; return; default: nn_fsm_bad_action (sinproc->state, src, type); } case NN_SINPROC_SRC_PEER: switch (type) { case NN_SINPROC_READY: sinproc->peer = (struct nn_sinproc*) srcptr; rc = nn_pipebase_start (&sinproc->pipebase); errnum_assert (rc == 0, -rc); sinproc->state = NN_SINPROC_STATE_ACTIVE; nn_fsm_raiseto (&sinproc->fsm, &sinproc->peer->fsm, &sinproc->event_connect, NN_SINPROC_SRC_PEER, NN_SINPROC_ACCEPTED, self); return; default: nn_fsm_bad_action (sinproc->state, src, type); } default: nn_fsm_bad_source (sinproc->state, src, type); } /******************************************************************************/ /* READY state. */ /* */ /******************************************************************************/ case NN_SINPROC_STATE_READY: switch (src) { case NN_SINPROC_SRC_PEER: switch (type) { case NN_SINPROC_READY: /* This means both peers sent READY so they are both ready for receiving messages */ rc = nn_pipebase_start (&sinproc->pipebase); errnum_assert (rc == 0, -rc); sinproc->state = NN_SINPROC_STATE_ACTIVE; return; case NN_SINPROC_ACCEPTED: rc = nn_pipebase_start (&sinproc->pipebase); errnum_assert (rc == 0, -rc); sinproc->state = NN_SINPROC_STATE_ACTIVE; return; default: nn_fsm_bad_action (sinproc->state, src, type); } default: nn_fsm_bad_source (sinproc->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /******************************************************************************/ case NN_SINPROC_STATE_ACTIVE: switch (src) { case NN_SINPROC_SRC_PEER: switch (type) { case NN_SINPROC_SENT: empty = nn_msgqueue_empty (&sinproc->msgqueue); /* Push the message to the inbound message queue. */ rc = nn_msgqueue_send (&sinproc->msgqueue, &sinproc->peer->msg); if (rc == -EAGAIN) { sinproc->flags |= NN_SINPROC_FLAG_RECEIVING; return; } errnum_assert (rc == 0, -rc); nn_msg_init (&sinproc->peer->msg, 0); /* Notify the user that there's a message to receive. */ if (empty) nn_pipebase_received (&sinproc->pipebase); /* Notify the peer that the message was received. */ nn_fsm_raiseto (&sinproc->fsm, &sinproc->peer->fsm, &sinproc->peer->event_received, NN_SINPROC_SRC_PEER, NN_SINPROC_RECEIVED, sinproc); return; case NN_SINPROC_RECEIVED: nn_assert (sinproc->flags & NN_SINPROC_FLAG_SENDING); nn_pipebase_sent (&sinproc->pipebase); sinproc->flags &= ~NN_SINPROC_FLAG_SENDING; return; case NN_SINPROC_DISCONNECT: nn_pipebase_stop (&sinproc->pipebase); nn_fsm_raiseto (&sinproc->fsm, &sinproc->peer->fsm, &sinproc->peer->event_disconnect, NN_SINPROC_SRC_PEER, NN_SINPROC_DISCONNECT, sinproc); sinproc->state = NN_SINPROC_STATE_DISCONNECTED; sinproc->peer = NULL; nn_fsm_raise (&sinproc->fsm, &sinproc->event_disconnect, NN_SINPROC_DISCONNECT); return; default: nn_fsm_bad_action (sinproc->state, src, type); } default: nn_fsm_bad_source (sinproc->state, src, type); } /******************************************************************************/ /* DISCONNECTED state. */ /* The peer have already closed the connection, but the object was not yet */ /* asked to stop. */ /******************************************************************************/ case NN_SINPROC_STATE_DISCONNECTED: switch (src) { case NN_SINPROC_SRC_PEER: switch (type) { case NN_SINPROC_RECEIVED: /* This case can safely be ignored. It may happen when nn_close() comes before the already enqueued NN_SINPROC_RECEIVED has been delivered. */ return; default: nn_fsm_bad_action (sinproc->state, src, type); }; default: nn_fsm_bad_source (sinproc->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (sinproc->state, src, type); } } nanomsg-0.8-beta/src/transports/ipc/0000775000175000017500000000000012623652617020433 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/transports/ipc/aipc.h0000664000175000017500000000516512623652600021517 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_AIPC_INCLUDED #define NN_AIPC_INCLUDED #include "sipc.h" #include "../../transport.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../../utils/list.h" /* State machine handling accepted IPC sockets. */ /* In bipc, some events are just *assumed* to come from a child aipc object. By using non-trivial event codes, we can do more reliable sanity checking in such scenarios. */ #define NN_AIPC_ACCEPTED 34231 #define NN_AIPC_ERROR 34232 #define NN_AIPC_STOPPED 34233 struct nn_aipc { /* The state machine. */ struct nn_fsm fsm; int state; /* Pointer to the associated endpoint. */ struct nn_epbase *epbase; /* Underlying socket. */ struct nn_usock usock; /* Listening socket. Valid only while accepting new connection. */ struct nn_usock *listener; struct nn_fsm_owner listener_owner; /* State machine that takes care of the connection in the active state. */ struct nn_sipc sipc; /* Events generated by aipc state machine. */ struct nn_fsm_event accepted; struct nn_fsm_event done; /* This member can be used by owner to keep individual aipcs in a list. */ struct nn_list_item item; }; void nn_aipc_init (struct nn_aipc *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner); void nn_aipc_term (struct nn_aipc *self); int nn_aipc_isidle (struct nn_aipc *self); void nn_aipc_start (struct nn_aipc *self, struct nn_usock *listener); void nn_aipc_stop (struct nn_aipc *self); #endif nanomsg-0.8-beta/src/transports/ipc/aipc.c0000664000175000017500000002526212623652600021512 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "aipc.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/attr.h" #define NN_AIPC_STATE_IDLE 1 #define NN_AIPC_STATE_ACCEPTING 2 #define NN_AIPC_STATE_ACTIVE 3 #define NN_AIPC_STATE_STOPPING_SIPC 4 #define NN_AIPC_STATE_STOPPING_USOCK 5 #define NN_AIPC_STATE_DONE 6 #define NN_AIPC_STATE_STOPPING_SIPC_FINAL 7 #define NN_AIPC_STATE_STOPPING 8 #define NN_AIPC_SRC_USOCK 1 #define NN_AIPC_SRC_SIPC 2 #define NN_AIPC_SRC_LISTENER 3 /* Private functions. */ static void nn_aipc_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_aipc_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); void nn_aipc_init (struct nn_aipc *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_aipc_handler, nn_aipc_shutdown, src, self, owner); self->state = NN_AIPC_STATE_IDLE; self->epbase = epbase; nn_usock_init (&self->usock, NN_AIPC_SRC_USOCK, &self->fsm); self->listener = NULL; self->listener_owner.src = -1; self->listener_owner.fsm = NULL; nn_sipc_init (&self->sipc, NN_AIPC_SRC_SIPC, epbase, &self->fsm); nn_fsm_event_init (&self->accepted); nn_fsm_event_init (&self->done); nn_list_item_init (&self->item); } void nn_aipc_term (struct nn_aipc *self) { nn_assert_state (self, NN_AIPC_STATE_IDLE); nn_list_item_term (&self->item); nn_fsm_event_term (&self->done); nn_fsm_event_term (&self->accepted); nn_sipc_term (&self->sipc); nn_usock_term (&self->usock); nn_fsm_term (&self->fsm); } int nn_aipc_isidle (struct nn_aipc *self) { return nn_fsm_isidle (&self->fsm); } void nn_aipc_start (struct nn_aipc *self, struct nn_usock *listener) { nn_assert_state (self, NN_AIPC_STATE_IDLE); /* Take ownership of the listener socket. */ self->listener = listener; self->listener_owner.src = NN_AIPC_SRC_LISTENER; self->listener_owner.fsm = &self->fsm; nn_usock_swap_owner (listener, &self->listener_owner); /* Start the state machine. */ nn_fsm_start (&self->fsm); } void nn_aipc_stop (struct nn_aipc *self) { nn_fsm_stop (&self->fsm); } static void nn_aipc_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_aipc *aipc; aipc = nn_cont (self, struct nn_aipc, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { if (!nn_sipc_isidle (&aipc->sipc)) { nn_epbase_stat_increment (aipc->epbase, NN_STAT_DROPPED_CONNECTIONS, 1); nn_sipc_stop (&aipc->sipc); } aipc->state = NN_AIPC_STATE_STOPPING_SIPC_FINAL; } if (nn_slow (aipc->state == NN_AIPC_STATE_STOPPING_SIPC_FINAL)) { if (!nn_sipc_isidle (&aipc->sipc)) return; nn_usock_stop (&aipc->usock); aipc->state = NN_AIPC_STATE_STOPPING; } if (nn_slow (aipc->state == NN_AIPC_STATE_STOPPING)) { if (!nn_usock_isidle (&aipc->usock)) return; if (aipc->listener) { nn_assert (aipc->listener_owner.fsm); nn_usock_swap_owner (aipc->listener, &aipc->listener_owner); aipc->listener = NULL; aipc->listener_owner.src = -1; aipc->listener_owner.fsm = NULL; } aipc->state = NN_AIPC_STATE_IDLE; nn_fsm_stopped (&aipc->fsm, NN_AIPC_STOPPED); return; } nn_fsm_bad_state(aipc->state, src, type); } static void nn_aipc_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_aipc *aipc; int val; size_t sz; aipc = nn_cont (self, struct nn_aipc, fsm); switch (aipc->state) { /******************************************************************************/ /* IDLE state. */ /* The state machine wasn't yet started. */ /******************************************************************************/ case NN_AIPC_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_usock_accept (&aipc->usock, aipc->listener); aipc->state = NN_AIPC_STATE_ACCEPTING; return; default: nn_fsm_bad_action (aipc->state, src, type); } default: nn_fsm_bad_source (aipc->state, src, type); } /******************************************************************************/ /* ACCEPTING state. */ /* Waiting for incoming connection. */ /******************************************************************************/ case NN_AIPC_STATE_ACCEPTING: switch (src) { case NN_AIPC_SRC_USOCK: switch (type) { case NN_USOCK_ACCEPTED: nn_epbase_clear_error (aipc->epbase); /* Set the relevant socket options. */ sz = sizeof (val); nn_epbase_getopt (aipc->epbase, NN_SOL_SOCKET, NN_SNDBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&aipc->usock, SOL_SOCKET, SO_SNDBUF, &val, sizeof (val)); sz = sizeof (val); nn_epbase_getopt (aipc->epbase, NN_SOL_SOCKET, NN_RCVBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&aipc->usock, SOL_SOCKET, SO_RCVBUF, &val, sizeof (val)); /* Return ownership of the listening socket to the parent. */ nn_usock_swap_owner (aipc->listener, &aipc->listener_owner); aipc->listener = NULL; aipc->listener_owner.src = -1; aipc->listener_owner.fsm = NULL; nn_fsm_raise (&aipc->fsm, &aipc->accepted, NN_AIPC_ACCEPTED); /* Start the sipc state machine. */ nn_usock_activate (&aipc->usock); nn_sipc_start (&aipc->sipc, &aipc->usock); aipc->state = NN_AIPC_STATE_ACTIVE; nn_epbase_stat_increment (aipc->epbase, NN_STAT_ACCEPTED_CONNECTIONS, 1); return; default: nn_fsm_bad_action (aipc->state, src, type); } case NN_AIPC_SRC_LISTENER: switch (type) { case NN_USOCK_ACCEPT_ERROR: nn_epbase_set_error (aipc->epbase, nn_usock_geterrno (aipc->listener)); nn_epbase_stat_increment (aipc->epbase, NN_STAT_ACCEPT_ERRORS, 1); nn_usock_accept (&aipc->usock, aipc->listener); return; default: nn_fsm_bad_action (aipc->state, src, type); } default: nn_fsm_bad_source (aipc->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /******************************************************************************/ case NN_AIPC_STATE_ACTIVE: switch (src) { case NN_AIPC_SRC_SIPC: switch (type) { case NN_SIPC_ERROR: nn_sipc_stop (&aipc->sipc); aipc->state = NN_AIPC_STATE_STOPPING_SIPC; nn_epbase_stat_increment (aipc->epbase, NN_STAT_BROKEN_CONNECTIONS, 1); return; default: nn_fsm_bad_action (aipc->state, src, type); } default: nn_fsm_bad_source (aipc->state, src, type); } /******************************************************************************/ /* STOPPING_SIPC state. */ /******************************************************************************/ case NN_AIPC_STATE_STOPPING_SIPC: switch (src) { case NN_AIPC_SRC_SIPC: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_SIPC_STOPPED: nn_usock_stop (&aipc->usock); aipc->state = NN_AIPC_STATE_STOPPING_USOCK; return; default: nn_fsm_bad_action (aipc->state, src, type); } default: nn_fsm_bad_source (aipc->state, src, type); } /******************************************************************************/ /* STOPPING_USOCK state. */ /******************************************************************************/ case NN_AIPC_STATE_STOPPING_USOCK: switch (src) { case NN_AIPC_SRC_USOCK: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_USOCK_STOPPED: nn_fsm_raise (&aipc->fsm, &aipc->done, NN_AIPC_ERROR); aipc->state = NN_AIPC_STATE_DONE; return; default: nn_fsm_bad_action (aipc->state, src, type); } default: nn_fsm_bad_source (aipc->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (aipc->state, src, type); } } nanomsg-0.8-beta/src/transports/ipc/bipc.h0000664000175000017500000000250512623652600021513 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_BIPC_INCLUDED #define NN_BIPC_INCLUDED #include "../../transport.h" /* State machine managing bound IPC socket. */ int nn_bipc_create (void *hint, struct nn_epbase **epbase); #endif nanomsg-0.8-beta/src/transports/ipc/bipc.c0000664000175000017500000003523612623652600021515 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "bipc.h" #include "aipc.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../utils/backoff.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/alloc.h" #include "../../utils/list.h" #include "../../utils/fast.h" #include #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #include #include #endif #define NN_BIPC_BACKLOG 10 #define NN_BIPC_STATE_IDLE 1 #define NN_BIPC_STATE_ACTIVE 2 #define NN_BIPC_STATE_STOPPING_AIPC 3 #define NN_BIPC_STATE_STOPPING_USOCK 4 #define NN_BIPC_STATE_STOPPING_AIPCS 5 #define NN_BIPC_STATE_LISTENING 6 #define NN_BIPC_STATE_WAITING 7 #define NN_BIPC_STATE_CLOSING 8 #define NN_BIPC_STATE_STOPPING_BACKOFF 9 #define NN_BIPC_SRC_USOCK 1 #define NN_BIPC_SRC_AIPC 2 #define NN_BIPC_SRC_RECONNECT_TIMER 3 struct nn_bipc { /* The state machine. */ struct nn_fsm fsm; int state; /* This object is a specific type of endpoint. Thus it is derived from epbase. */ struct nn_epbase epbase; /* The underlying listening IPC socket. */ struct nn_usock usock; /* The connection being accepted at the moment. */ struct nn_aipc *aipc; /* List of accepted connections. */ struct nn_list aipcs; /* Used to wait before retrying to connect. */ struct nn_backoff retry; }; /* nn_epbase virtual interface implementation. */ static void nn_bipc_stop (struct nn_epbase *self); static void nn_bipc_destroy (struct nn_epbase *self); const struct nn_epbase_vfptr nn_bipc_epbase_vfptr = { nn_bipc_stop, nn_bipc_destroy }; /* Private functions. */ static void nn_bipc_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_bipc_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_bipc_start_listening (struct nn_bipc *self); static void nn_bipc_start_accepting (struct nn_bipc *self); int nn_bipc_create (void *hint, struct nn_epbase **epbase) { struct nn_bipc *self; int reconnect_ivl; int reconnect_ivl_max; size_t sz; /* Allocate the new endpoint object. */ self = nn_alloc (sizeof (struct nn_bipc), "bipc"); alloc_assert (self); /* Initialise the structure. */ nn_epbase_init (&self->epbase, &nn_bipc_epbase_vfptr, hint); nn_fsm_init_root (&self->fsm, nn_bipc_handler, nn_bipc_shutdown, nn_epbase_getctx (&self->epbase)); self->state = NN_BIPC_STATE_IDLE; sz = sizeof (reconnect_ivl); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL, &reconnect_ivl, &sz); nn_assert (sz == sizeof (reconnect_ivl)); sz = sizeof (reconnect_ivl_max); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL_MAX, &reconnect_ivl_max, &sz); nn_assert (sz == sizeof (reconnect_ivl_max)); if (reconnect_ivl_max == 0) reconnect_ivl_max = reconnect_ivl; nn_backoff_init (&self->retry, NN_BIPC_SRC_RECONNECT_TIMER, reconnect_ivl, reconnect_ivl_max, &self->fsm); nn_usock_init (&self->usock, NN_BIPC_SRC_USOCK, &self->fsm); self->aipc = NULL; nn_list_init (&self->aipcs); /* Start the state machine. */ nn_fsm_start (&self->fsm); /* Return the base class as an out parameter. */ *epbase = &self->epbase; return 0; } static void nn_bipc_stop (struct nn_epbase *self) { struct nn_bipc *bipc; bipc = nn_cont (self, struct nn_bipc, epbase); nn_fsm_stop (&bipc->fsm); } static void nn_bipc_destroy (struct nn_epbase *self) { struct nn_bipc *bipc; bipc = nn_cont (self, struct nn_bipc, epbase); nn_assert_state (bipc, NN_BIPC_STATE_IDLE); nn_list_term (&bipc->aipcs); nn_assert (bipc->aipc == NULL); nn_usock_term (&bipc->usock); nn_backoff_term (&bipc->retry); nn_epbase_term (&bipc->epbase); nn_fsm_term (&bipc->fsm); nn_free (bipc); } static void nn_bipc_shutdown (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_bipc *bipc; struct nn_list_item *it; struct nn_aipc *aipc; bipc = nn_cont (self, struct nn_bipc, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { nn_backoff_stop (&bipc->retry); if (bipc->aipc) { nn_aipc_stop (bipc->aipc); bipc->state = NN_BIPC_STATE_STOPPING_AIPC; } else { bipc->state = NN_BIPC_STATE_STOPPING_USOCK; } } if (nn_slow (bipc->state == NN_BIPC_STATE_STOPPING_AIPC)) { if (!nn_aipc_isidle (bipc->aipc)) return; nn_aipc_term (bipc->aipc); nn_free (bipc->aipc); bipc->aipc = NULL; nn_usock_stop (&bipc->usock); bipc->state = NN_BIPC_STATE_STOPPING_USOCK; } if (nn_slow (bipc->state == NN_BIPC_STATE_STOPPING_USOCK)) { if (!nn_usock_isidle (&bipc->usock) || !nn_backoff_isidle (&bipc->retry)) return; for (it = nn_list_begin (&bipc->aipcs); it != nn_list_end (&bipc->aipcs); it = nn_list_next (&bipc->aipcs, it)) { aipc = nn_cont (it, struct nn_aipc, item); nn_aipc_stop (aipc); } bipc->state = NN_BIPC_STATE_STOPPING_AIPCS; goto aipcs_stopping; } if (nn_slow (bipc->state == NN_BIPC_STATE_STOPPING_AIPCS)) { nn_assert (src == NN_BIPC_SRC_AIPC && type == NN_AIPC_STOPPED); aipc = (struct nn_aipc *) srcptr; nn_list_erase (&bipc->aipcs, &aipc->item); nn_aipc_term (aipc); nn_free (aipc); /* If there are no more aipc state machines, we can stop the whole bipc object. */ aipcs_stopping: if (nn_list_empty (&bipc->aipcs)) { bipc->state = NN_BIPC_STATE_IDLE; nn_fsm_stopped_noevent (&bipc->fsm); nn_epbase_stopped (&bipc->epbase); return; } return; } nn_fsm_bad_state(bipc->state, src, type); } static void nn_bipc_handler (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_bipc *bipc; struct nn_aipc *aipc; bipc = nn_cont (self, struct nn_bipc, fsm); switch (bipc->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_BIPC_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_bipc_start_listening (bipc); return; default: nn_fsm_bad_action (bipc->state, src, type); } default: nn_fsm_bad_source (bipc->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /* The execution is yielded to the aipc state machine in this state. */ /******************************************************************************/ case NN_BIPC_STATE_ACTIVE: if (srcptr == bipc->aipc) { switch (type) { case NN_AIPC_ACCEPTED: /* Move the newly created connection to the list of existing connections. */ nn_list_insert (&bipc->aipcs, &bipc->aipc->item, nn_list_end (&bipc->aipcs)); bipc->aipc = NULL; /* Start waiting for a new incoming connection. */ nn_bipc_start_accepting (bipc); return; default: nn_fsm_bad_action (bipc->state, src, type); } } /* For all remaining events we'll assume they are coming from one of remaining child aipc objects. */ nn_assert (src == NN_BIPC_SRC_AIPC); aipc = (struct nn_aipc*) srcptr; switch (type) { case NN_AIPC_ERROR: nn_aipc_stop (aipc); return; case NN_AIPC_STOPPED: nn_list_erase (&bipc->aipcs, &aipc->item); nn_aipc_term (aipc); nn_free (aipc); return; default: nn_fsm_bad_action (bipc->state, src, type); } /******************************************************************************/ /* CLOSING_USOCK state. */ /* usock object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_BIPC_STATE_CLOSING: switch (src) { case NN_BIPC_SRC_USOCK: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_USOCK_STOPPED: nn_backoff_start (&bipc->retry); bipc->state = NN_BIPC_STATE_WAITING; return; default: nn_fsm_bad_action (bipc->state, src, type); } default: nn_fsm_bad_source (bipc->state, src, type); } /******************************************************************************/ /* WAITING state. */ /* Waiting before re-bind is attempted. This way we won't overload */ /* the system by continuous re-bind attemps. */ /******************************************************************************/ case NN_BIPC_STATE_WAITING: switch (src) { case NN_BIPC_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_TIMEOUT: nn_backoff_stop (&bipc->retry); bipc->state = NN_BIPC_STATE_STOPPING_BACKOFF; return; default: nn_fsm_bad_action (bipc->state, src, type); } default: nn_fsm_bad_source (bipc->state, src, type); } /******************************************************************************/ /* STOPPING_BACKOFF state. */ /* backoff object was asked to stop, but it haven't stopped yet. */ /******************************************************************************/ case NN_BIPC_STATE_STOPPING_BACKOFF: switch (src) { case NN_BIPC_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_STOPPED: nn_bipc_start_listening (bipc); return; default: nn_fsm_bad_action (bipc->state, src, type); } default: nn_fsm_bad_source (bipc->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (bipc->state, src, type); } } /******************************************************************************/ /* State machine actions. */ /******************************************************************************/ static void nn_bipc_start_listening (struct nn_bipc *self) { int rc; struct sockaddr_storage ss; struct sockaddr_un *un; const char *addr; #if !defined NN_HAVE_WINDOWS int fd; #endif /* First, create the AF_UNIX address. */ addr = nn_epbase_getaddr (&self->epbase); memset (&ss, 0, sizeof (ss)); un = (struct sockaddr_un*) &ss; nn_assert (strlen (addr) < sizeof (un->sun_path)); ss.ss_family = AF_UNIX; strncpy (un->sun_path, addr, sizeof (un->sun_path)); /* Delete the IPC file left over by eventual previous runs of the application. We'll check whether the file is still in use by connecting to the endpoint. On Windows plaform, NamedPipe is used which does not have an underlying file. */ #if !defined NN_HAVE_WINDOWS fd = socket (AF_UNIX, SOCK_STREAM, 0); if (fd >= 0) { rc = fcntl (fd, F_SETFL, O_NONBLOCK); errno_assert (rc != -1 || errno == EINVAL); rc = connect (fd, (struct sockaddr*) &ss, sizeof (struct sockaddr_un)); if (rc == -1 && errno == ECONNREFUSED) { rc = unlink (addr); errno_assert (rc == 0 || errno == ENOENT); } rc = close (fd); errno_assert (rc == 0); } #endif /* Start listening for incoming connections. */ rc = nn_usock_start (&self->usock, AF_UNIX, SOCK_STREAM, 0); if (nn_slow (rc < 0)) { nn_backoff_start (&self->retry); self->state = NN_BIPC_STATE_WAITING; return; } rc = nn_usock_bind (&self->usock, (struct sockaddr*) &ss, sizeof (struct sockaddr_un)); if (nn_slow (rc < 0)) { nn_usock_stop (&self->usock); self->state = NN_BIPC_STATE_CLOSING; return; } rc = nn_usock_listen (&self->usock, NN_BIPC_BACKLOG); if (nn_slow (rc < 0)) { nn_usock_stop (&self->usock); self->state = NN_BIPC_STATE_CLOSING; return; } nn_bipc_start_accepting (self); self->state = NN_BIPC_STATE_ACTIVE; } static void nn_bipc_start_accepting (struct nn_bipc *self) { nn_assert (self->aipc == NULL); /* Allocate new aipc state machine. */ self->aipc = nn_alloc (sizeof (struct nn_aipc), "aipc"); alloc_assert (self->aipc); nn_aipc_init (self->aipc, NN_BIPC_SRC_AIPC, &self->epbase, &self->fsm); /* Start waiting for a new incoming connection. */ nn_aipc_start (self->aipc, &self->usock); } nanomsg-0.8-beta/src/transports/ipc/cipc.h0000664000175000017500000000251112623652600021511 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_CIPC_INCLUDED #define NN_CIPC_INCLUDED #include "../../transport.h" /* State machine managing connected IPC socket. */ int nn_cipc_create (void *hint, struct nn_epbase **epbase); #endif nanomsg-0.8-beta/src/transports/ipc/cipc.c0000664000175000017500000003470412623652600021515 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "cipc.h" #include "sipc.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../utils/backoff.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/alloc.h" #include "../../utils/fast.h" #include "../../utils/attr.h" #include #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #include #endif #define NN_CIPC_STATE_IDLE 1 #define NN_CIPC_STATE_CONNECTING 2 #define NN_CIPC_STATE_ACTIVE 3 #define NN_CIPC_STATE_STOPPING_SIPC 4 #define NN_CIPC_STATE_STOPPING_USOCK 5 #define NN_CIPC_STATE_WAITING 6 #define NN_CIPC_STATE_STOPPING_BACKOFF 7 #define NN_CIPC_STATE_STOPPING_SIPC_FINAL 8 #define NN_CIPC_STATE_STOPPING 9 #define NN_CIPC_SRC_USOCK 1 #define NN_CIPC_SRC_RECONNECT_TIMER 2 #define NN_CIPC_SRC_SIPC 3 struct nn_cipc { /* The state machine. */ struct nn_fsm fsm; int state; /* This object is a specific type of endpoint. Thus it is derived from epbase. */ struct nn_epbase epbase; /* The underlying IPC socket. */ struct nn_usock usock; /* Used to wait before retrying to connect. */ struct nn_backoff retry; /* State machine that handles the active part of the connection lifetime. */ struct nn_sipc sipc; }; /* nn_epbase virtual interface implementation. */ static void nn_cipc_stop (struct nn_epbase *self); static void nn_cipc_destroy (struct nn_epbase *self); const struct nn_epbase_vfptr nn_cipc_epbase_vfptr = { nn_cipc_stop, nn_cipc_destroy }; /* Private functions. */ static void nn_cipc_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_cipc_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_cipc_start_connecting (struct nn_cipc *self); int nn_cipc_create (void *hint, struct nn_epbase **epbase) { struct nn_cipc *self; int reconnect_ivl; int reconnect_ivl_max; size_t sz; /* Allocate the new endpoint object. */ self = nn_alloc (sizeof (struct nn_cipc), "cipc"); alloc_assert (self); /* Initialise the structure. */ nn_epbase_init (&self->epbase, &nn_cipc_epbase_vfptr, hint); nn_fsm_init_root (&self->fsm, nn_cipc_handler, nn_cipc_shutdown, nn_epbase_getctx (&self->epbase)); self->state = NN_CIPC_STATE_IDLE; nn_usock_init (&self->usock, NN_CIPC_SRC_USOCK, &self->fsm); sz = sizeof (reconnect_ivl); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL, &reconnect_ivl, &sz); nn_assert (sz == sizeof (reconnect_ivl)); sz = sizeof (reconnect_ivl_max); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL_MAX, &reconnect_ivl_max, &sz); nn_assert (sz == sizeof (reconnect_ivl_max)); if (reconnect_ivl_max == 0) reconnect_ivl_max = reconnect_ivl; nn_backoff_init (&self->retry, NN_CIPC_SRC_RECONNECT_TIMER, reconnect_ivl, reconnect_ivl_max, &self->fsm); nn_sipc_init (&self->sipc, NN_CIPC_SRC_SIPC, &self->epbase, &self->fsm); /* Start the state machine. */ nn_fsm_start (&self->fsm); /* Return the base class as an out parameter. */ *epbase = &self->epbase; return 0; } static void nn_cipc_stop (struct nn_epbase *self) { struct nn_cipc *cipc; cipc = nn_cont (self, struct nn_cipc, epbase); nn_fsm_stop (&cipc->fsm); } static void nn_cipc_destroy (struct nn_epbase *self) { struct nn_cipc *cipc; cipc = nn_cont (self, struct nn_cipc, epbase); nn_sipc_term (&cipc->sipc); nn_backoff_term (&cipc->retry); nn_usock_term (&cipc->usock); nn_fsm_term (&cipc->fsm); nn_epbase_term (&cipc->epbase); nn_free (cipc); } static void nn_cipc_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_cipc *cipc; cipc = nn_cont (self, struct nn_cipc, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { if (!nn_sipc_isidle (&cipc->sipc)) { nn_epbase_stat_increment (&cipc->epbase, NN_STAT_DROPPED_CONNECTIONS, 1); nn_sipc_stop (&cipc->sipc); } cipc->state = NN_CIPC_STATE_STOPPING_SIPC_FINAL; } if (nn_slow (cipc->state == NN_CIPC_STATE_STOPPING_SIPC_FINAL)) { if (!nn_sipc_isidle (&cipc->sipc)) return; nn_backoff_stop (&cipc->retry); nn_usock_stop (&cipc->usock); cipc->state = NN_CIPC_STATE_STOPPING; } if (nn_slow (cipc->state == NN_CIPC_STATE_STOPPING)) { if (!nn_backoff_isidle (&cipc->retry) || !nn_usock_isidle (&cipc->usock)) return; cipc->state = NN_CIPC_STATE_IDLE; nn_fsm_stopped_noevent (&cipc->fsm); nn_epbase_stopped (&cipc->epbase); return; } nn_fsm_bad_state(cipc->state, src, type); } static void nn_cipc_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_cipc *cipc; cipc = nn_cont (self, struct nn_cipc, fsm); switch (cipc->state) { /******************************************************************************/ /* IDLE state. */ /* The state machine wasn't yet started. */ /******************************************************************************/ case NN_CIPC_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_cipc_start_connecting (cipc); return; default: nn_fsm_bad_action (cipc->state, src, type); } default: nn_fsm_bad_source (cipc->state, src, type); } /******************************************************************************/ /* CONNECTING state. */ /* Non-blocking connect is under way. */ /******************************************************************************/ case NN_CIPC_STATE_CONNECTING: switch (src) { case NN_CIPC_SRC_USOCK: switch (type) { case NN_USOCK_CONNECTED: nn_sipc_start (&cipc->sipc, &cipc->usock); cipc->state = NN_CIPC_STATE_ACTIVE; nn_epbase_stat_increment (&cipc->epbase, NN_STAT_INPROGRESS_CONNECTIONS, -1); nn_epbase_stat_increment (&cipc->epbase, NN_STAT_ESTABLISHED_CONNECTIONS, 1); nn_epbase_clear_error (&cipc->epbase); return; case NN_USOCK_ERROR: nn_epbase_set_error (&cipc->epbase, nn_usock_geterrno (&cipc->usock)); nn_usock_stop (&cipc->usock); cipc->state = NN_CIPC_STATE_STOPPING_USOCK; nn_epbase_stat_increment (&cipc->epbase, NN_STAT_INPROGRESS_CONNECTIONS, -1); nn_epbase_stat_increment (&cipc->epbase, NN_STAT_CONNECT_ERRORS, 1); return; default: nn_fsm_bad_action (cipc->state, src, type); } default: nn_fsm_bad_source (cipc->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /* Connection is established and handled by the sipc state machine. */ /******************************************************************************/ case NN_CIPC_STATE_ACTIVE: switch (src) { case NN_CIPC_SRC_SIPC: switch (type) { case NN_SIPC_ERROR: nn_sipc_stop (&cipc->sipc); cipc->state = NN_CIPC_STATE_STOPPING_SIPC; nn_epbase_stat_increment (&cipc->epbase, NN_STAT_BROKEN_CONNECTIONS, 1); return; default: nn_fsm_bad_action (cipc->state, src, type); } default: nn_fsm_bad_source (cipc->state, src, type); } /******************************************************************************/ /* STOPPING_SIPC state. */ /* sipc object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_CIPC_STATE_STOPPING_SIPC: switch (src) { case NN_CIPC_SRC_SIPC: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_SIPC_STOPPED: nn_usock_stop (&cipc->usock); cipc->state = NN_CIPC_STATE_STOPPING_USOCK; return; default: nn_fsm_bad_action (cipc->state, src, type); } default: nn_fsm_bad_source (cipc->state, src, type); } /******************************************************************************/ /* STOPPING_USOCK state. */ /* usock object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_CIPC_STATE_STOPPING_USOCK: switch (src) { case NN_CIPC_SRC_USOCK: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_USOCK_STOPPED: nn_backoff_start (&cipc->retry); cipc->state = NN_CIPC_STATE_WAITING; return; default: nn_fsm_bad_action (cipc->state, src, type); } default: nn_fsm_bad_source (cipc->state, src, type); } /******************************************************************************/ /* WAITING state. */ /* Waiting before re-connection is attempted. This way we won't overload */ /* the system by continuous re-connection attemps. */ /******************************************************************************/ case NN_CIPC_STATE_WAITING: switch (src) { case NN_CIPC_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_TIMEOUT: nn_backoff_stop (&cipc->retry); cipc->state = NN_CIPC_STATE_STOPPING_BACKOFF; return; default: nn_fsm_bad_action (cipc->state, src, type); } default: nn_fsm_bad_source (cipc->state, src, type); } /******************************************************************************/ /* STOPPING_BACKOFF state. */ /* backoff object was asked to stop, but it haven't stopped yet. */ /******************************************************************************/ case NN_CIPC_STATE_STOPPING_BACKOFF: switch (src) { case NN_CIPC_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_STOPPED: nn_cipc_start_connecting (cipc); return; default: nn_fsm_bad_action (cipc->state, src, type); } default: nn_fsm_bad_source (cipc->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (cipc->state, src, type); } } /******************************************************************************/ /* State machine actions. */ /******************************************************************************/ static void nn_cipc_start_connecting (struct nn_cipc *self) { int rc; struct sockaddr_storage ss; struct sockaddr_un *un; const char *addr; int val; size_t sz; /* Try to start the underlying socket. */ rc = nn_usock_start (&self->usock, AF_UNIX, SOCK_STREAM, 0); if (nn_slow (rc < 0)) { nn_backoff_start (&self->retry); self->state = NN_CIPC_STATE_WAITING; return; } /* Set the relevant socket options. */ sz = sizeof (val); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_SNDBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&self->usock, SOL_SOCKET, SO_SNDBUF, &val, sizeof (val)); sz = sizeof (val); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RCVBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&self->usock, SOL_SOCKET, SO_RCVBUF, &val, sizeof (val)); /* Create the IPC address from the address string. */ addr = nn_epbase_getaddr (&self->epbase); memset (&ss, 0, sizeof (ss)); un = (struct sockaddr_un*) &ss; nn_assert (strlen (addr) < sizeof (un->sun_path)); ss.ss_family = AF_UNIX; strncpy (un->sun_path, addr, sizeof (un->sun_path)); /* Start connecting. */ nn_usock_connect (&self->usock, (struct sockaddr*) &ss, sizeof (struct sockaddr_un)); self->state = NN_CIPC_STATE_CONNECTING; nn_epbase_stat_increment (&self->epbase, NN_STAT_INPROGRESS_CONNECTIONS, 1); } nanomsg-0.8-beta/src/transports/ipc/ipc.h0000664000175000017500000000237712623652600021360 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_IPC_INCLUDED #define NN_IPC_INCLUDED #include "../../transport.h" extern struct nn_transport *nn_ipc; #endif nanomsg-0.8-beta/src/transports/ipc/ipc.c0000664000175000017500000000417212623652600021346 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "ipc.h" #include "bipc.h" #include "cipc.h" #include "../../ipc.h" #include "../../utils/err.h" #include "../../utils/alloc.h" #include "../../utils/fast.h" #include "../../utils/list.h" #include #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #include #include #endif /* nn_transport interface. */ static int nn_ipc_bind (void *hint, struct nn_epbase **epbase); static int nn_ipc_connect (void *hint, struct nn_epbase **epbase); static struct nn_transport nn_ipc_vfptr = { "ipc", NN_IPC, NULL, NULL, nn_ipc_bind, nn_ipc_connect, NULL, NN_LIST_ITEM_INITIALIZER }; struct nn_transport *nn_ipc = &nn_ipc_vfptr; static int nn_ipc_bind (void *hint, struct nn_epbase **epbase) { return nn_bipc_create (hint, epbase); } static int nn_ipc_connect (void *hint, struct nn_epbase **epbase) { return nn_cipc_create (hint, epbase); } nanomsg-0.8-beta/src/transports/ipc/sipc.h0000664000175000017500000000540212623652600021533 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_SIPC_INCLUDED #define NN_SIPC_INCLUDED #include "../../transport.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../utils/streamhdr.h" #include "../../utils/msg.h" /* This state machine handles IPC connection from the point where it is established to the point when it is broken. */ #define NN_SIPC_ERROR 1 #define NN_SIPC_STOPPED 2 struct nn_sipc { /* The state machine. */ struct nn_fsm fsm; int state; /* The underlying socket. */ struct nn_usock *usock; /* Child state machine to do protocol header exchange. */ struct nn_streamhdr streamhdr; /* The original owner of the underlying socket. */ struct nn_fsm_owner usock_owner; /* Pipe connecting this IPC connection to the nanomsg core. */ struct nn_pipebase pipebase; /* State of inbound state machine. */ int instate; /* Buffer used to store the header of incoming message. */ uint8_t inhdr [9]; /* Message being received at the moment. */ struct nn_msg inmsg; /* State of the outbound state machine. */ int outstate; /* Buffer used to store the header of outgoing message. */ uint8_t outhdr [9]; /* Message being sent at the moment. */ struct nn_msg outmsg; /* Event raised when the state machine ends. */ struct nn_fsm_event done; }; void nn_sipc_init (struct nn_sipc *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner); void nn_sipc_term (struct nn_sipc *self); int nn_sipc_isidle (struct nn_sipc *self); void nn_sipc_start (struct nn_sipc *self, struct nn_usock *usock); void nn_sipc_stop (struct nn_sipc *self); #endif nanomsg-0.8-beta/src/transports/ipc/sipc.c0000664000175000017500000003447312623652600021540 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "sipc.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/wire.h" #include "../../utils/int.h" #include "../../utils/attr.h" /* Types of messages passed via IPC transport. */ #define NN_SIPC_MSG_NORMAL 1 #define NN_SIPC_MSG_SHMEM 2 /* States of the object as a whole. */ #define NN_SIPC_STATE_IDLE 1 #define NN_SIPC_STATE_PROTOHDR 2 #define NN_SIPC_STATE_STOPPING_STREAMHDR 3 #define NN_SIPC_STATE_ACTIVE 4 #define NN_SIPC_STATE_SHUTTING_DOWN 5 #define NN_SIPC_STATE_DONE 6 #define NN_SIPC_STATE_STOPPING 7 /* Subordinated srcptr objects. */ #define NN_SIPC_SRC_USOCK 1 #define NN_SIPC_SRC_STREAMHDR 2 /* Possible states of the inbound part of the object. */ #define NN_SIPC_INSTATE_HDR 1 #define NN_SIPC_INSTATE_BODY 2 #define NN_SIPC_INSTATE_HASMSG 3 /* Possible states of the outbound part of the object. */ #define NN_SIPC_OUTSTATE_IDLE 1 #define NN_SIPC_OUTSTATE_SENDING 2 /* Stream is a special type of pipe. Implementation of the virtual pipe API. */ static int nn_sipc_send (struct nn_pipebase *self, struct nn_msg *msg); static int nn_sipc_recv (struct nn_pipebase *self, struct nn_msg *msg); const struct nn_pipebase_vfptr nn_sipc_pipebase_vfptr = { nn_sipc_send, nn_sipc_recv }; /* Private functions. */ static void nn_sipc_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_sipc_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); void nn_sipc_init (struct nn_sipc *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_sipc_handler, nn_sipc_shutdown, src, self, owner); self->state = NN_SIPC_STATE_IDLE; nn_streamhdr_init (&self->streamhdr, NN_SIPC_SRC_STREAMHDR, &self->fsm); self->usock = NULL; self->usock_owner.src = -1; self->usock_owner.fsm = NULL; nn_pipebase_init (&self->pipebase, &nn_sipc_pipebase_vfptr, epbase); self->instate = -1; nn_msg_init (&self->inmsg, 0); self->outstate = -1; nn_msg_init (&self->outmsg, 0); nn_fsm_event_init (&self->done); } void nn_sipc_term (struct nn_sipc *self) { nn_assert_state (self, NN_SIPC_STATE_IDLE); nn_fsm_event_term (&self->done); nn_msg_term (&self->outmsg); nn_msg_term (&self->inmsg); nn_pipebase_term (&self->pipebase); nn_streamhdr_term (&self->streamhdr); nn_fsm_term (&self->fsm); } int nn_sipc_isidle (struct nn_sipc *self) { return nn_fsm_isidle (&self->fsm); } void nn_sipc_start (struct nn_sipc *self, struct nn_usock *usock) { /* Take ownership of the underlying socket. */ nn_assert (self->usock == NULL && self->usock_owner.fsm == NULL); self->usock_owner.src = NN_SIPC_SRC_USOCK; self->usock_owner.fsm = &self->fsm; nn_usock_swap_owner (usock, &self->usock_owner); self->usock = usock; /* Launch the state machine. */ nn_fsm_start (&self->fsm); } void nn_sipc_stop (struct nn_sipc *self) { nn_fsm_stop (&self->fsm); } static int nn_sipc_send (struct nn_pipebase *self, struct nn_msg *msg) { struct nn_sipc *sipc; struct nn_iovec iov [3]; sipc = nn_cont (self, struct nn_sipc, pipebase); nn_assert_state (sipc, NN_SIPC_STATE_ACTIVE); nn_assert (sipc->outstate == NN_SIPC_OUTSTATE_IDLE); /* Move the message to the local storage. */ nn_msg_term (&sipc->outmsg); nn_msg_mv (&sipc->outmsg, msg); /* Serialise the message header. */ sipc->outhdr [0] = NN_SIPC_MSG_NORMAL; nn_putll (sipc->outhdr + 1, nn_chunkref_size (&sipc->outmsg.sphdr) + nn_chunkref_size (&sipc->outmsg.body)); /* Start async sending. */ iov [0].iov_base = sipc->outhdr; iov [0].iov_len = sizeof (sipc->outhdr); iov [1].iov_base = nn_chunkref_data (&sipc->outmsg.sphdr); iov [1].iov_len = nn_chunkref_size (&sipc->outmsg.sphdr); iov [2].iov_base = nn_chunkref_data (&sipc->outmsg.body); iov [2].iov_len = nn_chunkref_size (&sipc->outmsg.body); nn_usock_send (sipc->usock, iov, 3); sipc->outstate = NN_SIPC_OUTSTATE_SENDING; return 0; } static int nn_sipc_recv (struct nn_pipebase *self, struct nn_msg *msg) { struct nn_sipc *sipc; sipc = nn_cont (self, struct nn_sipc, pipebase); nn_assert_state (sipc, NN_SIPC_STATE_ACTIVE); nn_assert (sipc->instate == NN_SIPC_INSTATE_HASMSG); /* Move received message to the user. */ nn_msg_mv (msg, &sipc->inmsg); nn_msg_init (&sipc->inmsg, 0); /* Start receiving new message. */ sipc->instate = NN_SIPC_INSTATE_HDR; nn_usock_recv (sipc->usock, sipc->inhdr, sizeof (sipc->inhdr), NULL); return 0; } static void nn_sipc_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_sipc *sipc; sipc = nn_cont (self, struct nn_sipc, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { nn_pipebase_stop (&sipc->pipebase); nn_streamhdr_stop (&sipc->streamhdr); sipc->state = NN_SIPC_STATE_STOPPING; } if (nn_slow (sipc->state == NN_SIPC_STATE_STOPPING)) { if (nn_streamhdr_isidle (&sipc->streamhdr)) { nn_usock_swap_owner (sipc->usock, &sipc->usock_owner); sipc->usock = NULL; sipc->usock_owner.src = -1; sipc->usock_owner.fsm = NULL; sipc->state = NN_SIPC_STATE_IDLE; nn_fsm_stopped (&sipc->fsm, NN_SIPC_STOPPED); return; } return; } nn_fsm_bad_state(sipc->state, src, type); } static void nn_sipc_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { int rc; struct nn_sipc *sipc; uint64_t size; sipc = nn_cont (self, struct nn_sipc, fsm); switch (sipc->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_SIPC_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_streamhdr_start (&sipc->streamhdr, sipc->usock, &sipc->pipebase); sipc->state = NN_SIPC_STATE_PROTOHDR; return; default: nn_fsm_bad_action (sipc->state, src, type); } default: nn_fsm_bad_source (sipc->state, src, type); } /******************************************************************************/ /* PROTOHDR state. */ /******************************************************************************/ case NN_SIPC_STATE_PROTOHDR: switch (src) { case NN_SIPC_SRC_STREAMHDR: switch (type) { case NN_STREAMHDR_OK: /* Before moving to the active state stop the streamhdr state machine. */ nn_streamhdr_stop (&sipc->streamhdr); sipc->state = NN_SIPC_STATE_STOPPING_STREAMHDR; return; case NN_STREAMHDR_ERROR: /* Raise the error and move directly to the DONE state. streamhdr object will be stopped later on. */ sipc->state = NN_SIPC_STATE_DONE; nn_fsm_raise (&sipc->fsm, &sipc->done, NN_SIPC_ERROR); return; default: nn_fsm_bad_action (sipc->state, src, type); } default: nn_fsm_bad_source (sipc->state, src, type); } /******************************************************************************/ /* STOPPING_STREAMHDR state. */ /******************************************************************************/ case NN_SIPC_STATE_STOPPING_STREAMHDR: switch (src) { case NN_SIPC_SRC_STREAMHDR: switch (type) { case NN_STREAMHDR_STOPPED: /* Start the pipe. */ rc = nn_pipebase_start (&sipc->pipebase); if (nn_slow (rc < 0)) { sipc->state = NN_SIPC_STATE_DONE; nn_fsm_raise (&sipc->fsm, &sipc->done, NN_SIPC_ERROR); return; } /* Start receiving a message in asynchronous manner. */ sipc->instate = NN_SIPC_INSTATE_HDR; nn_usock_recv (sipc->usock, &sipc->inhdr, sizeof (sipc->inhdr), NULL); /* Mark the pipe as available for sending. */ sipc->outstate = NN_SIPC_OUTSTATE_IDLE; sipc->state = NN_SIPC_STATE_ACTIVE; return; default: nn_fsm_bad_action (sipc->state, src, type); } default: nn_fsm_bad_source (sipc->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /******************************************************************************/ case NN_SIPC_STATE_ACTIVE: switch (src) { case NN_SIPC_SRC_USOCK: switch (type) { case NN_USOCK_SENT: /* The message is now fully sent. */ nn_assert (sipc->outstate == NN_SIPC_OUTSTATE_SENDING); sipc->outstate = NN_SIPC_OUTSTATE_IDLE; nn_msg_term (&sipc->outmsg); nn_msg_init (&sipc->outmsg, 0); nn_pipebase_sent (&sipc->pipebase); return; case NN_USOCK_RECEIVED: switch (sipc->instate) { case NN_SIPC_INSTATE_HDR: /* Message header was received. Allocate memory for the message. */ nn_assert (sipc->inhdr [0] == NN_SIPC_MSG_NORMAL); size = nn_getll (sipc->inhdr + 1); nn_msg_term (&sipc->inmsg); nn_msg_init (&sipc->inmsg, (size_t) size); /* Special case when size of the message body is 0. */ if (!size) { sipc->instate = NN_SIPC_INSTATE_HASMSG; nn_pipebase_received (&sipc->pipebase); return; } /* Start receiving the message body. */ sipc->instate = NN_SIPC_INSTATE_BODY; nn_usock_recv (sipc->usock, nn_chunkref_data (&sipc->inmsg.body), (size_t) size, NULL); return; case NN_SIPC_INSTATE_BODY: /* Message body was received. Notify the owner that it can receive it. */ sipc->instate = NN_SIPC_INSTATE_HASMSG; nn_pipebase_received (&sipc->pipebase); return; default: nn_assert (0); } case NN_USOCK_SHUTDOWN: nn_pipebase_stop (&sipc->pipebase); sipc->state = NN_SIPC_STATE_SHUTTING_DOWN; return; case NN_USOCK_ERROR: nn_pipebase_stop (&sipc->pipebase); sipc->state = NN_SIPC_STATE_DONE; nn_fsm_raise (&sipc->fsm, &sipc->done, NN_SIPC_ERROR); return; default: nn_fsm_bad_action (sipc->state, src, type); } default: nn_fsm_bad_source (sipc->state, src, type); } /******************************************************************************/ /* SHUTTING_DOWN state. */ /* The underlying connection is closed. We are just waiting that underlying */ /* usock being closed */ /******************************************************************************/ case NN_SIPC_STATE_SHUTTING_DOWN: switch (src) { case NN_SIPC_SRC_USOCK: switch (type) { case NN_USOCK_ERROR: sipc->state = NN_SIPC_STATE_DONE; nn_fsm_raise (&sipc->fsm, &sipc->done, NN_SIPC_ERROR); return; default: nn_fsm_bad_action (sipc->state, src, type); } default: nn_fsm_bad_source (sipc->state, src, type); } /******************************************************************************/ /* DONE state. */ /* The underlying connection is closed. There's nothing that can be done in */ /* this state except stopping the object. */ /******************************************************************************/ case NN_SIPC_STATE_DONE: nn_fsm_bad_source (sipc->state, src, type); /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (sipc->state, src, type); } } nanomsg-0.8-beta/src/transports/tcp/0000775000175000017500000000000012623652617020446 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/transports/tcp/atcp.h0000664000175000017500000000516512623652600021545 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_ATCP_INCLUDED #define NN_ATCP_INCLUDED #include "stcp.h" #include "../../transport.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../../utils/list.h" /* State machine handling accepted TCP sockets. */ /* In btcp, some events are just *assumed* to come from a child atcp object. By using non-trivial event codes, we can do more reliable sanity checking in such scenarios. */ #define NN_ATCP_ACCEPTED 34231 #define NN_ATCP_ERROR 34232 #define NN_ATCP_STOPPED 34233 struct nn_atcp { /* The state machine. */ struct nn_fsm fsm; int state; /* Pointer to the associated endpoint. */ struct nn_epbase *epbase; /* Underlying socket. */ struct nn_usock usock; /* Listening socket. Valid only while accepting new connection. */ struct nn_usock *listener; struct nn_fsm_owner listener_owner; /* State machine that takes care of the connection in the active state. */ struct nn_stcp stcp; /* Events generated by atcp state machine. */ struct nn_fsm_event accepted; struct nn_fsm_event done; /* This member can be used by owner to keep individual atcps in a list. */ struct nn_list_item item; }; void nn_atcp_init (struct nn_atcp *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner); void nn_atcp_term (struct nn_atcp *self); int nn_atcp_isidle (struct nn_atcp *self); void nn_atcp_start (struct nn_atcp *self, struct nn_usock *listener); void nn_atcp_stop (struct nn_atcp *self); #endif nanomsg-0.8-beta/src/transports/tcp/atcp.c0000664000175000017500000002526512623652600021543 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "atcp.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/attr.h" #define NN_ATCP_STATE_IDLE 1 #define NN_ATCP_STATE_ACCEPTING 2 #define NN_ATCP_STATE_ACTIVE 3 #define NN_ATCP_STATE_STOPPING_STCP 4 #define NN_ATCP_STATE_STOPPING_USOCK 5 #define NN_ATCP_STATE_DONE 6 #define NN_ATCP_STATE_STOPPING_STCP_FINAL 7 #define NN_ATCP_STATE_STOPPING 8 #define NN_ATCP_SRC_USOCK 1 #define NN_ATCP_SRC_STCP 2 #define NN_ATCP_SRC_LISTENER 3 /* Private functions. */ static void nn_atcp_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_atcp_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); void nn_atcp_init (struct nn_atcp *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_atcp_handler, nn_atcp_shutdown, src, self, owner); self->state = NN_ATCP_STATE_IDLE; self->epbase = epbase; nn_usock_init (&self->usock, NN_ATCP_SRC_USOCK, &self->fsm); self->listener = NULL; self->listener_owner.src = -1; self->listener_owner.fsm = NULL; nn_stcp_init (&self->stcp, NN_ATCP_SRC_STCP, epbase, &self->fsm); nn_fsm_event_init (&self->accepted); nn_fsm_event_init (&self->done); nn_list_item_init (&self->item); } void nn_atcp_term (struct nn_atcp *self) { nn_assert_state (self, NN_ATCP_STATE_IDLE); nn_list_item_term (&self->item); nn_fsm_event_term (&self->done); nn_fsm_event_term (&self->accepted); nn_stcp_term (&self->stcp); nn_usock_term (&self->usock); nn_fsm_term (&self->fsm); } int nn_atcp_isidle (struct nn_atcp *self) { return nn_fsm_isidle (&self->fsm); } void nn_atcp_start (struct nn_atcp *self, struct nn_usock *listener) { nn_assert_state (self, NN_ATCP_STATE_IDLE); /* Take ownership of the listener socket. */ self->listener = listener; self->listener_owner.src = NN_ATCP_SRC_LISTENER; self->listener_owner.fsm = &self->fsm; nn_usock_swap_owner (listener, &self->listener_owner); /* Start the state machine. */ nn_fsm_start (&self->fsm); } void nn_atcp_stop (struct nn_atcp *self) { nn_fsm_stop (&self->fsm); } static void nn_atcp_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_atcp *atcp; atcp = nn_cont (self, struct nn_atcp, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { if (!nn_stcp_isidle (&atcp->stcp)) { nn_epbase_stat_increment (atcp->epbase, NN_STAT_DROPPED_CONNECTIONS, 1); nn_stcp_stop (&atcp->stcp); } atcp->state = NN_ATCP_STATE_STOPPING_STCP_FINAL; } if (nn_slow (atcp->state == NN_ATCP_STATE_STOPPING_STCP_FINAL)) { if (!nn_stcp_isidle (&atcp->stcp)) return; nn_usock_stop (&atcp->usock); atcp->state = NN_ATCP_STATE_STOPPING; } if (nn_slow (atcp->state == NN_ATCP_STATE_STOPPING)) { if (!nn_usock_isidle (&atcp->usock)) return; if (atcp->listener) { nn_assert (atcp->listener_owner.fsm); nn_usock_swap_owner (atcp->listener, &atcp->listener_owner); atcp->listener = NULL; atcp->listener_owner.src = -1; atcp->listener_owner.fsm = NULL; } atcp->state = NN_ATCP_STATE_IDLE; nn_fsm_stopped (&atcp->fsm, NN_ATCP_STOPPED); return; } nn_fsm_bad_action(atcp->state, src, type); } static void nn_atcp_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_atcp *atcp; int val; size_t sz; atcp = nn_cont (self, struct nn_atcp, fsm); switch (atcp->state) { /******************************************************************************/ /* IDLE state. */ /* The state machine wasn't yet started. */ /******************************************************************************/ case NN_ATCP_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_usock_accept (&atcp->usock, atcp->listener); atcp->state = NN_ATCP_STATE_ACCEPTING; return; default: nn_fsm_bad_action (atcp->state, src, type); } default: nn_fsm_bad_source (atcp->state, src, type); } /******************************************************************************/ /* ACCEPTING state. */ /* Waiting for incoming connection. */ /******************************************************************************/ case NN_ATCP_STATE_ACCEPTING: switch (src) { case NN_ATCP_SRC_USOCK: switch (type) { case NN_USOCK_ACCEPTED: nn_epbase_clear_error (atcp->epbase); /* Set the relevant socket options. */ sz = sizeof (val); nn_epbase_getopt (atcp->epbase, NN_SOL_SOCKET, NN_SNDBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&atcp->usock, SOL_SOCKET, SO_SNDBUF, &val, sizeof (val)); sz = sizeof (val); nn_epbase_getopt (atcp->epbase, NN_SOL_SOCKET, NN_RCVBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&atcp->usock, SOL_SOCKET, SO_RCVBUF, &val, sizeof (val)); /* Return ownership of the listening socket to the parent. */ nn_usock_swap_owner (atcp->listener, &atcp->listener_owner); atcp->listener = NULL; atcp->listener_owner.src = -1; atcp->listener_owner.fsm = NULL; nn_fsm_raise (&atcp->fsm, &atcp->accepted, NN_ATCP_ACCEPTED); /* Start the stcp state machine. */ nn_usock_activate (&atcp->usock); nn_stcp_start (&atcp->stcp, &atcp->usock); atcp->state = NN_ATCP_STATE_ACTIVE; nn_epbase_stat_increment (atcp->epbase, NN_STAT_ACCEPTED_CONNECTIONS, 1); return; default: nn_fsm_bad_action (atcp->state, src, type); } case NN_ATCP_SRC_LISTENER: switch (type) { case NN_USOCK_ACCEPT_ERROR: nn_epbase_set_error (atcp->epbase, nn_usock_geterrno(atcp->listener)); nn_epbase_stat_increment (atcp->epbase, NN_STAT_ACCEPT_ERRORS, 1); nn_usock_accept (&atcp->usock, atcp->listener); return; default: nn_fsm_bad_action (atcp->state, src, type); } default: nn_fsm_bad_source (atcp->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /******************************************************************************/ case NN_ATCP_STATE_ACTIVE: switch (src) { case NN_ATCP_SRC_STCP: switch (type) { case NN_STCP_ERROR: nn_stcp_stop (&atcp->stcp); atcp->state = NN_ATCP_STATE_STOPPING_STCP; nn_epbase_stat_increment (atcp->epbase, NN_STAT_BROKEN_CONNECTIONS, 1); return; default: nn_fsm_bad_action (atcp->state, src, type); } default: nn_fsm_bad_source (atcp->state, src, type); } /******************************************************************************/ /* STOPPING_STCP state. */ /******************************************************************************/ case NN_ATCP_STATE_STOPPING_STCP: switch (src) { case NN_ATCP_SRC_STCP: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_STCP_STOPPED: nn_usock_stop (&atcp->usock); atcp->state = NN_ATCP_STATE_STOPPING_USOCK; return; default: nn_fsm_bad_action (atcp->state, src, type); } default: nn_fsm_bad_source (atcp->state, src, type); } /******************************************************************************/ /* STOPPING_USOCK state. */ /******************************************************************************/ case NN_ATCP_STATE_STOPPING_USOCK: switch (src) { case NN_ATCP_SRC_USOCK: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_USOCK_STOPPED: nn_fsm_raise (&atcp->fsm, &atcp->done, NN_ATCP_ERROR); atcp->state = NN_ATCP_STATE_DONE; return; default: nn_fsm_bad_action (atcp->state, src, type); } default: nn_fsm_bad_source (atcp->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (atcp->state, src, type); } } nanomsg-0.8-beta/src/transports/tcp/btcp.h0000664000175000017500000000250612623652600021542 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_BTCP_INCLUDED #define NN_BTCP_INCLUDED #include "../../transport.h" /* State machine managing bound TCP socket. */ int nn_btcp_create (void *hint, struct nn_epbase **epbase); #endif nanomsg-0.8-beta/src/transports/tcp/btcp.c0000664000175000017500000003755112623652600021545 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "btcp.h" #include "atcp.h" #include "../utils/port.h" #include "../utils/iface.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../utils/backoff.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/alloc.h" #include "../../utils/list.h" #include "../../utils/fast.h" #include "../../utils/int.h" #include #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #include #endif /* The backlog is set relatively high so that there are not too many failed connection attemps during re-connection storms. */ #define NN_BTCP_BACKLOG 100 #define NN_BTCP_STATE_IDLE 1 #define NN_BTCP_STATE_ACTIVE 2 #define NN_BTCP_STATE_STOPPING_ATCP 3 #define NN_BTCP_STATE_STOPPING_USOCK 4 #define NN_BTCP_STATE_STOPPING_ATCPS 5 #define NN_BTCP_STATE_LISTENING 6 #define NN_BTCP_STATE_WAITING 7 #define NN_BTCP_STATE_CLOSING 8 #define NN_BTCP_STATE_STOPPING_BACKOFF 9 #define NN_BTCP_SRC_USOCK 1 #define NN_BTCP_SRC_ATCP 2 #define NN_BTCP_SRC_RECONNECT_TIMER 3 struct nn_btcp { /* The state machine. */ struct nn_fsm fsm; int state; /* This object is a specific type of endpoint. Thus it is derived from epbase. */ struct nn_epbase epbase; /* The underlying listening TCP socket. */ struct nn_usock usock; /* The connection being accepted at the moment. */ struct nn_atcp *atcp; /* List of accepted connections. */ struct nn_list atcps; /* Used to wait before retrying to connect. */ struct nn_backoff retry; }; /* nn_epbase virtual interface implementation. */ static void nn_btcp_stop (struct nn_epbase *self); static void nn_btcp_destroy (struct nn_epbase *self); const struct nn_epbase_vfptr nn_btcp_epbase_vfptr = { nn_btcp_stop, nn_btcp_destroy }; /* Private functions. */ static void nn_btcp_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_btcp_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_btcp_start_listening (struct nn_btcp *self); static void nn_btcp_start_accepting (struct nn_btcp *self); int nn_btcp_create (void *hint, struct nn_epbase **epbase) { int rc; struct nn_btcp *self; const char *addr; const char *end; const char *pos; struct sockaddr_storage ss; size_t sslen; int ipv4only; size_t ipv4onlylen; int reconnect_ivl; int reconnect_ivl_max; size_t sz; /* Allocate the new endpoint object. */ self = nn_alloc (sizeof (struct nn_btcp), "btcp"); alloc_assert (self); /* Initalise the epbase. */ nn_epbase_init (&self->epbase, &nn_btcp_epbase_vfptr, hint); addr = nn_epbase_getaddr (&self->epbase); /* Parse the port. */ end = addr + strlen (addr); pos = strrchr (addr, ':'); if (nn_slow (!pos)) { nn_epbase_term (&self->epbase); return -EINVAL; } ++pos; rc = nn_port_resolve (pos, end - pos); if (nn_slow (rc < 0)) { nn_epbase_term (&self->epbase); return -EINVAL; } /* Check whether IPv6 is to be used. */ ipv4onlylen = sizeof (ipv4only); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY, &ipv4only, &ipv4onlylen); nn_assert (ipv4onlylen == sizeof (ipv4only)); /* Parse the address. */ rc = nn_iface_resolve (addr, pos - addr - 1, ipv4only, &ss, &sslen); if (nn_slow (rc < 0)) { nn_epbase_term (&self->epbase); return -ENODEV; } /* Initialise the structure. */ nn_fsm_init_root (&self->fsm, nn_btcp_handler, nn_btcp_shutdown, nn_epbase_getctx (&self->epbase)); self->state = NN_BTCP_STATE_IDLE; sz = sizeof (reconnect_ivl); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL, &reconnect_ivl, &sz); nn_assert (sz == sizeof (reconnect_ivl)); sz = sizeof (reconnect_ivl_max); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL_MAX, &reconnect_ivl_max, &sz); nn_assert (sz == sizeof (reconnect_ivl_max)); if (reconnect_ivl_max == 0) reconnect_ivl_max = reconnect_ivl; nn_backoff_init (&self->retry, NN_BTCP_SRC_RECONNECT_TIMER, reconnect_ivl, reconnect_ivl_max, &self->fsm); nn_usock_init (&self->usock, NN_BTCP_SRC_USOCK, &self->fsm); self->atcp = NULL; nn_list_init (&self->atcps); /* Start the state machine. */ nn_fsm_start (&self->fsm); /* Return the base class as an out parameter. */ *epbase = &self->epbase; return 0; } static void nn_btcp_stop (struct nn_epbase *self) { struct nn_btcp *btcp; btcp = nn_cont (self, struct nn_btcp, epbase); nn_fsm_stop (&btcp->fsm); } static void nn_btcp_destroy (struct nn_epbase *self) { struct nn_btcp *btcp; btcp = nn_cont (self, struct nn_btcp, epbase); nn_assert_state (btcp, NN_BTCP_STATE_IDLE); nn_list_term (&btcp->atcps); nn_assert (btcp->atcp == NULL); nn_usock_term (&btcp->usock); nn_backoff_term (&btcp->retry); nn_epbase_term (&btcp->epbase); nn_fsm_term (&btcp->fsm); nn_free (btcp); } static void nn_btcp_shutdown (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_btcp *btcp; struct nn_list_item *it; struct nn_atcp *atcp; btcp = nn_cont (self, struct nn_btcp, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { nn_backoff_stop (&btcp->retry); if (btcp->atcp) { nn_atcp_stop (btcp->atcp); btcp->state = NN_BTCP_STATE_STOPPING_ATCP; } else { btcp->state = NN_BTCP_STATE_STOPPING_USOCK; } } if (nn_slow (btcp->state == NN_BTCP_STATE_STOPPING_ATCP)) { if (!nn_atcp_isidle (btcp->atcp)) return; nn_atcp_term (btcp->atcp); nn_free (btcp->atcp); btcp->atcp = NULL; nn_usock_stop (&btcp->usock); btcp->state = NN_BTCP_STATE_STOPPING_USOCK; } if (nn_slow (btcp->state == NN_BTCP_STATE_STOPPING_USOCK)) { if (!nn_usock_isidle (&btcp->usock) || !nn_backoff_isidle (&btcp->retry)) return; for (it = nn_list_begin (&btcp->atcps); it != nn_list_end (&btcp->atcps); it = nn_list_next (&btcp->atcps, it)) { atcp = nn_cont (it, struct nn_atcp, item); nn_atcp_stop (atcp); } btcp->state = NN_BTCP_STATE_STOPPING_ATCPS; goto atcps_stopping; } if (nn_slow (btcp->state == NN_BTCP_STATE_STOPPING_ATCPS)) { nn_assert (src == NN_BTCP_SRC_ATCP && type == NN_ATCP_STOPPED); atcp = (struct nn_atcp *) srcptr; nn_list_erase (&btcp->atcps, &atcp->item); nn_atcp_term (atcp); nn_free (atcp); /* If there are no more atcp state machines, we can stop the whole btcp object. */ atcps_stopping: if (nn_list_empty (&btcp->atcps)) { btcp->state = NN_BTCP_STATE_IDLE; nn_fsm_stopped_noevent (&btcp->fsm); nn_epbase_stopped (&btcp->epbase); return; } return; } nn_fsm_bad_action(btcp->state, src, type); } static void nn_btcp_handler (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_btcp *btcp; struct nn_atcp *atcp; btcp = nn_cont (self, struct nn_btcp, fsm); switch (btcp->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_BTCP_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_btcp_start_listening (btcp); return; default: nn_fsm_bad_action (btcp->state, src, type); } default: nn_fsm_bad_source (btcp->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /* The execution is yielded to the atcp state machine in this state. */ /******************************************************************************/ case NN_BTCP_STATE_ACTIVE: if (srcptr == btcp->atcp) { switch (type) { case NN_ATCP_ACCEPTED: /* Move the newly created connection to the list of existing connections. */ nn_list_insert (&btcp->atcps, &btcp->atcp->item, nn_list_end (&btcp->atcps)); btcp->atcp = NULL; /* Start waiting for a new incoming connection. */ nn_btcp_start_accepting (btcp); return; default: nn_fsm_bad_action (btcp->state, src, type); } } /* For all remaining events we'll assume they are coming from one of remaining child atcp objects. */ nn_assert (src == NN_BTCP_SRC_ATCP); atcp = (struct nn_atcp*) srcptr; switch (type) { case NN_ATCP_ERROR: nn_atcp_stop (atcp); return; case NN_ATCP_STOPPED: nn_list_erase (&btcp->atcps, &atcp->item); nn_atcp_term (atcp); nn_free (atcp); return; default: nn_fsm_bad_action (btcp->state, src, type); } /******************************************************************************/ /* CLOSING_USOCK state. */ /* usock object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_BTCP_STATE_CLOSING: switch (src) { case NN_BTCP_SRC_USOCK: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_USOCK_STOPPED: nn_backoff_start (&btcp->retry); btcp->state = NN_BTCP_STATE_WAITING; return; default: nn_fsm_bad_action (btcp->state, src, type); } default: nn_fsm_bad_source (btcp->state, src, type); } /******************************************************************************/ /* WAITING state. */ /* Waiting before re-bind is attempted. This way we won't overload */ /* the system by continuous re-bind attemps. */ /******************************************************************************/ case NN_BTCP_STATE_WAITING: switch (src) { case NN_BTCP_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_TIMEOUT: nn_backoff_stop (&btcp->retry); btcp->state = NN_BTCP_STATE_STOPPING_BACKOFF; return; default: nn_fsm_bad_action (btcp->state, src, type); } default: nn_fsm_bad_source (btcp->state, src, type); } /******************************************************************************/ /* STOPPING_BACKOFF state. */ /* backoff object was asked to stop, but it haven't stopped yet. */ /******************************************************************************/ case NN_BTCP_STATE_STOPPING_BACKOFF: switch (src) { case NN_BTCP_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_STOPPED: nn_btcp_start_listening (btcp); return; default: nn_fsm_bad_action (btcp->state, src, type); } default: nn_fsm_bad_source (btcp->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (btcp->state, src, type); } } /******************************************************************************/ /* State machine actions. */ /******************************************************************************/ static void nn_btcp_start_listening (struct nn_btcp *self) { int rc; struct sockaddr_storage ss; size_t sslen; int ipv4only; size_t ipv4onlylen; const char *addr; const char *end; const char *pos; uint16_t port; /* First, resolve the IP address. */ addr = nn_epbase_getaddr (&self->epbase); memset (&ss, 0, sizeof (ss)); /* Parse the port. */ end = addr + strlen (addr); pos = strrchr (addr, ':'); nn_assert (pos); ++pos; rc = nn_port_resolve (pos, end - pos); nn_assert (rc >= 0); port = rc; /* Parse the address. */ ipv4onlylen = sizeof (ipv4only); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY, &ipv4only, &ipv4onlylen); nn_assert (ipv4onlylen == sizeof (ipv4only)); rc = nn_iface_resolve (addr, pos - addr - 1, ipv4only, &ss, &sslen); errnum_assert (rc == 0, -rc); /* Combine the port and the address. */ if (ss.ss_family == AF_INET) { ((struct sockaddr_in*) &ss)->sin_port = htons (port); sslen = sizeof (struct sockaddr_in); } else if (ss.ss_family == AF_INET6) { ((struct sockaddr_in6*) &ss)->sin6_port = htons (port); sslen = sizeof (struct sockaddr_in6); } else nn_assert (0); /* Start listening for incoming connections. */ rc = nn_usock_start (&self->usock, ss.ss_family, SOCK_STREAM, 0); if (nn_slow (rc < 0)) { nn_backoff_start (&self->retry); self->state = NN_BTCP_STATE_WAITING; return; } rc = nn_usock_bind (&self->usock, (struct sockaddr*) &ss, (size_t) sslen); if (nn_slow (rc < 0)) { nn_usock_stop (&self->usock); self->state = NN_BTCP_STATE_CLOSING; return; } rc = nn_usock_listen (&self->usock, NN_BTCP_BACKLOG); if (nn_slow (rc < 0)) { nn_usock_stop (&self->usock); self->state = NN_BTCP_STATE_CLOSING; return; } nn_btcp_start_accepting(self); self->state = NN_BTCP_STATE_ACTIVE; } static void nn_btcp_start_accepting (struct nn_btcp *self) { nn_assert (self->atcp == NULL); /* Allocate new atcp state machine. */ self->atcp = nn_alloc (sizeof (struct nn_atcp), "atcp"); alloc_assert (self->atcp); nn_atcp_init (self->atcp, NN_BTCP_SRC_ATCP, &self->epbase, &self->fsm); /* Start waiting for a new incoming connection. */ nn_atcp_start (self->atcp, &self->usock); } nanomsg-0.8-beta/src/transports/tcp/ctcp.h0000664000175000017500000000251212623652600021540 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_CTCP_INCLUDED #define NN_CTCP_INCLUDED #include "../../transport.h" /* State machine managing connected TCP socket. */ int nn_ctcp_create (void *hint, struct nn_epbase **epbase); #endif nanomsg-0.8-beta/src/transports/tcp/ctcp.c0000664000175000017500000005157612623652600021551 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "ctcp.h" #include "stcp.h" #include "../../tcp.h" #include "../utils/dns.h" #include "../utils/port.h" #include "../utils/iface.h" #include "../utils/backoff.h" #include "../utils/literal.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/alloc.h" #include "../../utils/fast.h" #include "../../utils/int.h" #include "../../utils/attr.h" #include #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #include #include #endif #define NN_CTCP_STATE_IDLE 1 #define NN_CTCP_STATE_RESOLVING 2 #define NN_CTCP_STATE_STOPPING_DNS 3 #define NN_CTCP_STATE_CONNECTING 4 #define NN_CTCP_STATE_ACTIVE 5 #define NN_CTCP_STATE_STOPPING_STCP 6 #define NN_CTCP_STATE_STOPPING_USOCK 7 #define NN_CTCP_STATE_WAITING 8 #define NN_CTCP_STATE_STOPPING_BACKOFF 9 #define NN_CTCP_STATE_STOPPING_STCP_FINAL 10 #define NN_CTCP_STATE_STOPPING 11 #define NN_CTCP_SRC_USOCK 1 #define NN_CTCP_SRC_RECONNECT_TIMER 2 #define NN_CTCP_SRC_DNS 3 #define NN_CTCP_SRC_STCP 4 struct nn_ctcp { /* The state machine. */ struct nn_fsm fsm; int state; /* This object is a specific type of endpoint. Thus it is derived from epbase. */ struct nn_epbase epbase; /* The underlying TCP socket. */ struct nn_usock usock; /* Used to wait before retrying to connect. */ struct nn_backoff retry; /* State machine that handles the active part of the connection lifetime. */ struct nn_stcp stcp; /* DNS resolver used to convert textual address into actual IP address along with the variable to hold the result. */ struct nn_dns dns; struct nn_dns_result dns_result; }; /* nn_epbase virtual interface implementation. */ static void nn_ctcp_stop (struct nn_epbase *self); static void nn_ctcp_destroy (struct nn_epbase *self); const struct nn_epbase_vfptr nn_ctcp_epbase_vfptr = { nn_ctcp_stop, nn_ctcp_destroy }; /* Private functions. */ static void nn_ctcp_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_ctcp_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_ctcp_start_resolving (struct nn_ctcp *self); static void nn_ctcp_start_connecting (struct nn_ctcp *self, struct sockaddr_storage *ss, size_t sslen); int nn_ctcp_create (void *hint, struct nn_epbase **epbase) { int rc; const char *addr; size_t addrlen; const char *semicolon; const char *hostname; const char *colon; const char *end; struct sockaddr_storage ss; size_t sslen; int ipv4only; size_t ipv4onlylen; struct nn_ctcp *self; int reconnect_ivl; int reconnect_ivl_max; size_t sz; /* Allocate the new endpoint object. */ self = nn_alloc (sizeof (struct nn_ctcp), "ctcp"); alloc_assert (self); /* Initalise the endpoint. */ nn_epbase_init (&self->epbase, &nn_ctcp_epbase_vfptr, hint); /* Check whether IPv6 is to be used. */ ipv4onlylen = sizeof (ipv4only); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY, &ipv4only, &ipv4onlylen); nn_assert (ipv4onlylen == sizeof (ipv4only)); /* Start parsing the address. */ addr = nn_epbase_getaddr (&self->epbase); addrlen = strlen (addr); semicolon = strchr (addr, ';'); hostname = semicolon ? semicolon + 1 : addr; colon = strrchr (addr, ':'); end = addr + addrlen; /* Parse the port. */ if (nn_slow (!colon)) { nn_epbase_term (&self->epbase); return -EINVAL; } rc = nn_port_resolve (colon + 1, end - colon - 1); if (nn_slow (rc < 0)) { nn_epbase_term (&self->epbase); return -EINVAL; } /* Check whether the host portion of the address is either a literal or a valid hostname. */ if (nn_dns_check_hostname (hostname, colon - hostname) < 0 && nn_literal_resolve (hostname, colon - hostname, ipv4only, &ss, &sslen) < 0) { nn_epbase_term (&self->epbase); return -EINVAL; } /* If local address is specified, check whether it is valid. */ if (semicolon) { rc = nn_iface_resolve (addr, semicolon - addr, ipv4only, &ss, &sslen); if (rc < 0) { nn_epbase_term (&self->epbase); return -ENODEV; } } /* Initialise the structure. */ nn_fsm_init_root (&self->fsm, nn_ctcp_handler, nn_ctcp_shutdown, nn_epbase_getctx (&self->epbase)); self->state = NN_CTCP_STATE_IDLE; nn_usock_init (&self->usock, NN_CTCP_SRC_USOCK, &self->fsm); sz = sizeof (reconnect_ivl); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL, &reconnect_ivl, &sz); nn_assert (sz == sizeof (reconnect_ivl)); sz = sizeof (reconnect_ivl_max); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL_MAX, &reconnect_ivl_max, &sz); nn_assert (sz == sizeof (reconnect_ivl_max)); if (reconnect_ivl_max == 0) reconnect_ivl_max = reconnect_ivl; nn_backoff_init (&self->retry, NN_CTCP_SRC_RECONNECT_TIMER, reconnect_ivl, reconnect_ivl_max, &self->fsm); nn_stcp_init (&self->stcp, NN_CTCP_SRC_STCP, &self->epbase, &self->fsm); nn_dns_init (&self->dns, NN_CTCP_SRC_DNS, &self->fsm); /* Start the state machine. */ nn_fsm_start (&self->fsm); /* Return the base class as an out parameter. */ *epbase = &self->epbase; return 0; } static void nn_ctcp_stop (struct nn_epbase *self) { struct nn_ctcp *ctcp; ctcp = nn_cont (self, struct nn_ctcp, epbase); nn_fsm_stop (&ctcp->fsm); } static void nn_ctcp_destroy (struct nn_epbase *self) { struct nn_ctcp *ctcp; ctcp = nn_cont (self, struct nn_ctcp, epbase); nn_dns_term (&ctcp->dns); nn_stcp_term (&ctcp->stcp); nn_backoff_term (&ctcp->retry); nn_usock_term (&ctcp->usock); nn_fsm_term (&ctcp->fsm); nn_epbase_term (&ctcp->epbase); nn_free (ctcp); } static void nn_ctcp_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_ctcp *ctcp; ctcp = nn_cont (self, struct nn_ctcp, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { if (!nn_stcp_isidle (&ctcp->stcp)) { nn_epbase_stat_increment (&ctcp->epbase, NN_STAT_DROPPED_CONNECTIONS, 1); nn_stcp_stop (&ctcp->stcp); } ctcp->state = NN_CTCP_STATE_STOPPING_STCP_FINAL; } if (nn_slow (ctcp->state == NN_CTCP_STATE_STOPPING_STCP_FINAL)) { if (!nn_stcp_isidle (&ctcp->stcp)) return; nn_backoff_stop (&ctcp->retry); nn_usock_stop (&ctcp->usock); nn_dns_stop (&ctcp->dns); ctcp->state = NN_CTCP_STATE_STOPPING; } if (nn_slow (ctcp->state == NN_CTCP_STATE_STOPPING)) { if (!nn_backoff_isidle (&ctcp->retry) || !nn_usock_isidle (&ctcp->usock) || !nn_dns_isidle (&ctcp->dns)) return; ctcp->state = NN_CTCP_STATE_IDLE; nn_fsm_stopped_noevent (&ctcp->fsm); nn_epbase_stopped (&ctcp->epbase); return; } nn_fsm_bad_state (ctcp->state, src, type); } static void nn_ctcp_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_ctcp *ctcp; ctcp = nn_cont (self, struct nn_ctcp, fsm); switch (ctcp->state) { /******************************************************************************/ /* IDLE state. */ /* The state machine wasn't yet started. */ /******************************************************************************/ case NN_CTCP_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_ctcp_start_resolving (ctcp); return; default: nn_fsm_bad_action (ctcp->state, src, type); } default: nn_fsm_bad_source (ctcp->state, src, type); } /******************************************************************************/ /* RESOLVING state. */ /* Name of the host to connect to is being resolved to get an IP address. */ /******************************************************************************/ case NN_CTCP_STATE_RESOLVING: switch (src) { case NN_CTCP_SRC_DNS: switch (type) { case NN_DNS_DONE: nn_dns_stop (&ctcp->dns); ctcp->state = NN_CTCP_STATE_STOPPING_DNS; return; default: nn_fsm_bad_action (ctcp->state, src, type); } default: nn_fsm_bad_source (ctcp->state, src, type); } /******************************************************************************/ /* STOPPING_DNS state. */ /* dns object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_CTCP_STATE_STOPPING_DNS: switch (src) { case NN_CTCP_SRC_DNS: switch (type) { case NN_DNS_STOPPED: if (ctcp->dns_result.error == 0) { nn_ctcp_start_connecting (ctcp, &ctcp->dns_result.addr, ctcp->dns_result.addrlen); return; } nn_backoff_start (&ctcp->retry); ctcp->state = NN_CTCP_STATE_WAITING; return; default: nn_fsm_bad_action (ctcp->state, src, type); } default: nn_fsm_bad_source (ctcp->state, src, type); } /******************************************************************************/ /* CONNECTING state. */ /* Non-blocking connect is under way. */ /******************************************************************************/ case NN_CTCP_STATE_CONNECTING: switch (src) { case NN_CTCP_SRC_USOCK: switch (type) { case NN_USOCK_CONNECTED: nn_stcp_start (&ctcp->stcp, &ctcp->usock); ctcp->state = NN_CTCP_STATE_ACTIVE; nn_epbase_stat_increment (&ctcp->epbase, NN_STAT_INPROGRESS_CONNECTIONS, -1); nn_epbase_stat_increment (&ctcp->epbase, NN_STAT_ESTABLISHED_CONNECTIONS, 1); nn_epbase_clear_error (&ctcp->epbase); return; case NN_USOCK_ERROR: nn_epbase_set_error (&ctcp->epbase, nn_usock_geterrno (&ctcp->usock)); nn_usock_stop (&ctcp->usock); ctcp->state = NN_CTCP_STATE_STOPPING_USOCK; nn_epbase_stat_increment (&ctcp->epbase, NN_STAT_INPROGRESS_CONNECTIONS, -1); nn_epbase_stat_increment (&ctcp->epbase, NN_STAT_CONNECT_ERRORS, 1); return; default: nn_fsm_bad_action (ctcp->state, src, type); } default: nn_fsm_bad_source (ctcp->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /* Connection is established and handled by the stcp state machine. */ /******************************************************************************/ case NN_CTCP_STATE_ACTIVE: switch (src) { case NN_CTCP_SRC_STCP: switch (type) { case NN_STCP_ERROR: nn_stcp_stop (&ctcp->stcp); ctcp->state = NN_CTCP_STATE_STOPPING_STCP; nn_epbase_stat_increment (&ctcp->epbase, NN_STAT_BROKEN_CONNECTIONS, 1); return; default: nn_fsm_bad_action (ctcp->state, src, type); } default: nn_fsm_bad_source (ctcp->state, src, type); } /******************************************************************************/ /* STOPPING_STCP state. */ /* stcp object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_CTCP_STATE_STOPPING_STCP: switch (src) { case NN_CTCP_SRC_STCP: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_STCP_STOPPED: nn_usock_stop (&ctcp->usock); ctcp->state = NN_CTCP_STATE_STOPPING_USOCK; return; default: nn_fsm_bad_action (ctcp->state, src, type); } default: nn_fsm_bad_source (ctcp->state, src, type); } /******************************************************************************/ /* STOPPING_USOCK state. */ /* usock object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_CTCP_STATE_STOPPING_USOCK: switch (src) { case NN_CTCP_SRC_USOCK: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_USOCK_STOPPED: nn_backoff_start (&ctcp->retry); ctcp->state = NN_CTCP_STATE_WAITING; return; default: nn_fsm_bad_action (ctcp->state, src, type); } default: nn_fsm_bad_source (ctcp->state, src, type); } /******************************************************************************/ /* WAITING state. */ /* Waiting before re-connection is attempted. This way we won't overload */ /* the system by continuous re-connection attemps. */ /******************************************************************************/ case NN_CTCP_STATE_WAITING: switch (src) { case NN_CTCP_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_TIMEOUT: nn_backoff_stop (&ctcp->retry); ctcp->state = NN_CTCP_STATE_STOPPING_BACKOFF; return; default: nn_fsm_bad_action (ctcp->state, src, type); } default: nn_fsm_bad_source (ctcp->state, src, type); } /******************************************************************************/ /* STOPPING_BACKOFF state. */ /* backoff object was asked to stop, but it haven't stopped yet. */ /******************************************************************************/ case NN_CTCP_STATE_STOPPING_BACKOFF: switch (src) { case NN_CTCP_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_STOPPED: nn_ctcp_start_resolving (ctcp); return; default: nn_fsm_bad_action (ctcp->state, src, type); } default: nn_fsm_bad_source (ctcp->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (ctcp->state, src, type); } } /******************************************************************************/ /* State machine actions. */ /******************************************************************************/ static void nn_ctcp_start_resolving (struct nn_ctcp *self) { const char *addr; const char *begin; const char *end; int ipv4only; size_t ipv4onlylen; /* Extract the hostname part from address string. */ addr = nn_epbase_getaddr (&self->epbase); begin = strchr (addr, ';'); if (!begin) begin = addr; else ++begin; end = strrchr (addr, ':'); nn_assert (end); /* Check whether IPv6 is to be used. */ ipv4onlylen = sizeof (ipv4only); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY, &ipv4only, &ipv4onlylen); nn_assert (ipv4onlylen == sizeof (ipv4only)); /* TODO: Get the actual value of IPV4ONLY option. */ nn_dns_start (&self->dns, begin, end - begin, ipv4only, &self->dns_result); self->state = NN_CTCP_STATE_RESOLVING; } static void nn_ctcp_start_connecting (struct nn_ctcp *self, struct sockaddr_storage *ss, size_t sslen) { int rc; struct sockaddr_storage remote; size_t remotelen; struct sockaddr_storage local; size_t locallen; const char *addr; const char *end; const char *colon; const char *semicolon; uint16_t port; int ipv4only; size_t ipv4onlylen; int val; size_t sz; /* Create IP address from the address string. */ addr = nn_epbase_getaddr (&self->epbase); memset (&remote, 0, sizeof (remote)); /* Parse the port. */ end = addr + strlen (addr); colon = strrchr (addr, ':'); rc = nn_port_resolve (colon + 1, end - colon - 1); errnum_assert (rc > 0, -rc); port = rc; /* Check whether IPv6 is to be used. */ ipv4onlylen = sizeof (ipv4only); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY, &ipv4only, &ipv4onlylen); nn_assert (ipv4onlylen == sizeof (ipv4only)); /* Parse the local address, if any. */ semicolon = strchr (addr, ';'); memset (&local, 0, sizeof (local)); if (semicolon) rc = nn_iface_resolve (addr, semicolon - addr, ipv4only, &local, &locallen); else rc = nn_iface_resolve ("*", 1, ipv4only, &local, &locallen); if (nn_slow (rc < 0)) { nn_backoff_start (&self->retry); self->state = NN_CTCP_STATE_WAITING; return; } /* Combine the remote address and the port. */ remote = *ss; remotelen = sslen; if (remote.ss_family == AF_INET) ((struct sockaddr_in*) &remote)->sin_port = htons (port); else if (remote.ss_family == AF_INET6) ((struct sockaddr_in6*) &remote)->sin6_port = htons (port); else nn_assert (0); /* Try to start the underlying socket. */ rc = nn_usock_start (&self->usock, remote.ss_family, SOCK_STREAM, 0); if (nn_slow (rc < 0)) { nn_backoff_start (&self->retry); self->state = NN_CTCP_STATE_WAITING; return; } /* Set the relevant socket options. */ sz = sizeof (val); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_SNDBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&self->usock, SOL_SOCKET, SO_SNDBUF, &val, sizeof (val)); sz = sizeof (val); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RCVBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&self->usock, SOL_SOCKET, SO_RCVBUF, &val, sizeof (val)); /* Bind the socket to the local network interface. */ rc = nn_usock_bind (&self->usock, (struct sockaddr*) &local, locallen); if (nn_slow (rc != 0)) { nn_backoff_start (&self->retry); self->state = NN_CTCP_STATE_WAITING; return; } /* Start connecting. */ nn_usock_connect (&self->usock, (struct sockaddr*) &remote, remotelen); self->state = NN_CTCP_STATE_CONNECTING; nn_epbase_stat_increment (&self->epbase, NN_STAT_INPROGRESS_CONNECTIONS, 1); } nanomsg-0.8-beta/src/transports/tcp/stcp.h0000664000175000017500000000540312623652600021562 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_STCP_INCLUDED #define NN_STCP_INCLUDED #include "../../transport.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../utils/streamhdr.h" #include "../../utils/msg.h" /* This state machine handles TCP connection from the point where it is established to the point when it is broken. */ #define NN_STCP_ERROR 1 #define NN_STCP_STOPPED 2 struct nn_stcp { /* The state machine. */ struct nn_fsm fsm; int state; /* The underlying socket. */ struct nn_usock *usock; /* Child state machine to do protocol header exchange. */ struct nn_streamhdr streamhdr; /* The original owner of the underlying socket. */ struct nn_fsm_owner usock_owner; /* Pipe connecting this TCP connection to the nanomsg core. */ struct nn_pipebase pipebase; /* State of inbound state machine. */ int instate; /* Buffer used to store the header of incoming message. */ uint8_t inhdr [8]; /* Message being received at the moment. */ struct nn_msg inmsg; /* State of the outbound state machine. */ int outstate; /* Buffer used to store the header of outgoing message. */ uint8_t outhdr [8]; /* Message being sent at the moment. */ struct nn_msg outmsg; /* Event raised when the state machine ends. */ struct nn_fsm_event done; }; void nn_stcp_init (struct nn_stcp *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner); void nn_stcp_term (struct nn_stcp *self); int nn_stcp_isidle (struct nn_stcp *self); void nn_stcp_start (struct nn_stcp *self, struct nn_usock *usock); void nn_stcp_stop (struct nn_stcp *self); #endif nanomsg-0.8-beta/src/transports/tcp/stcp.c0000664000175000017500000003535312623652600021564 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "stcp.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/wire.h" #include "../../utils/int.h" #include "../../utils/attr.h" /* States of the object as a whole. */ #define NN_STCP_STATE_IDLE 1 #define NN_STCP_STATE_PROTOHDR 2 #define NN_STCP_STATE_STOPPING_STREAMHDR 3 #define NN_STCP_STATE_ACTIVE 4 #define NN_STCP_STATE_SHUTTING_DOWN 5 #define NN_STCP_STATE_DONE 6 #define NN_STCP_STATE_STOPPING 7 /* Possible states of the inbound part of the object. */ #define NN_STCP_INSTATE_HDR 1 #define NN_STCP_INSTATE_BODY 2 #define NN_STCP_INSTATE_HASMSG 3 /* Possible states of the outbound part of the object. */ #define NN_STCP_OUTSTATE_IDLE 1 #define NN_STCP_OUTSTATE_SENDING 2 /* Subordinate srcptr objects. */ #define NN_STCP_SRC_USOCK 1 #define NN_STCP_SRC_STREAMHDR 2 /* Stream is a special type of pipe. Implementation of the virtual pipe API. */ static int nn_stcp_send (struct nn_pipebase *self, struct nn_msg *msg); static int nn_stcp_recv (struct nn_pipebase *self, struct nn_msg *msg); const struct nn_pipebase_vfptr nn_stcp_pipebase_vfptr = { nn_stcp_send, nn_stcp_recv }; /* Private functions. */ static void nn_stcp_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_stcp_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); void nn_stcp_init (struct nn_stcp *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_stcp_handler, nn_stcp_shutdown, src, self, owner); self->state = NN_STCP_STATE_IDLE; nn_streamhdr_init (&self->streamhdr, NN_STCP_SRC_STREAMHDR, &self->fsm); self->usock = NULL; self->usock_owner.src = -1; self->usock_owner.fsm = NULL; nn_pipebase_init (&self->pipebase, &nn_stcp_pipebase_vfptr, epbase); self->instate = -1; nn_msg_init (&self->inmsg, 0); self->outstate = -1; nn_msg_init (&self->outmsg, 0); nn_fsm_event_init (&self->done); } void nn_stcp_term (struct nn_stcp *self) { nn_assert_state (self, NN_STCP_STATE_IDLE); nn_fsm_event_term (&self->done); nn_msg_term (&self->outmsg); nn_msg_term (&self->inmsg); nn_pipebase_term (&self->pipebase); nn_streamhdr_term (&self->streamhdr); nn_fsm_term (&self->fsm); } int nn_stcp_isidle (struct nn_stcp *self) { return nn_fsm_isidle (&self->fsm); } void nn_stcp_start (struct nn_stcp *self, struct nn_usock *usock) { /* Take ownership of the underlying socket. */ nn_assert (self->usock == NULL && self->usock_owner.fsm == NULL); self->usock_owner.src = NN_STCP_SRC_USOCK; self->usock_owner.fsm = &self->fsm; nn_usock_swap_owner (usock, &self->usock_owner); self->usock = usock; /* Launch the state machine. */ nn_fsm_start (&self->fsm); } void nn_stcp_stop (struct nn_stcp *self) { nn_fsm_stop (&self->fsm); } static int nn_stcp_send (struct nn_pipebase *self, struct nn_msg *msg) { struct nn_stcp *stcp; struct nn_iovec iov [3]; stcp = nn_cont (self, struct nn_stcp, pipebase); nn_assert_state (stcp, NN_STCP_STATE_ACTIVE); nn_assert (stcp->outstate == NN_STCP_OUTSTATE_IDLE); /* Move the message to the local storage. */ nn_msg_term (&stcp->outmsg); nn_msg_mv (&stcp->outmsg, msg); /* Serialise the message header. */ nn_putll (stcp->outhdr, nn_chunkref_size (&stcp->outmsg.sphdr) + nn_chunkref_size (&stcp->outmsg.body)); /* Start async sending. */ iov [0].iov_base = stcp->outhdr; iov [0].iov_len = sizeof (stcp->outhdr); iov [1].iov_base = nn_chunkref_data (&stcp->outmsg.sphdr); iov [1].iov_len = nn_chunkref_size (&stcp->outmsg.sphdr); iov [2].iov_base = nn_chunkref_data (&stcp->outmsg.body); iov [2].iov_len = nn_chunkref_size (&stcp->outmsg.body); nn_usock_send (stcp->usock, iov, 3); stcp->outstate = NN_STCP_OUTSTATE_SENDING; return 0; } static int nn_stcp_recv (struct nn_pipebase *self, struct nn_msg *msg) { struct nn_stcp *stcp; stcp = nn_cont (self, struct nn_stcp, pipebase); nn_assert_state (stcp, NN_STCP_STATE_ACTIVE); nn_assert (stcp->instate == NN_STCP_INSTATE_HASMSG); /* Move received message to the user. */ nn_msg_mv (msg, &stcp->inmsg); nn_msg_init (&stcp->inmsg, 0); /* Start receiving new message. */ stcp->instate = NN_STCP_INSTATE_HDR; nn_usock_recv (stcp->usock, stcp->inhdr, sizeof (stcp->inhdr), NULL); return 0; } static void nn_stcp_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_stcp *stcp; stcp = nn_cont (self, struct nn_stcp, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { nn_pipebase_stop (&stcp->pipebase); nn_streamhdr_stop (&stcp->streamhdr); stcp->state = NN_STCP_STATE_STOPPING; } if (nn_slow (stcp->state == NN_STCP_STATE_STOPPING)) { if (nn_streamhdr_isidle (&stcp->streamhdr)) { nn_usock_swap_owner (stcp->usock, &stcp->usock_owner); stcp->usock = NULL; stcp->usock_owner.src = -1; stcp->usock_owner.fsm = NULL; stcp->state = NN_STCP_STATE_IDLE; nn_fsm_stopped (&stcp->fsm, NN_STCP_STOPPED); return; } return; } nn_fsm_bad_state(stcp->state, src, type); } static void nn_stcp_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { int rc; struct nn_stcp *stcp; uint64_t size; int opt; size_t opt_sz = sizeof (opt); stcp = nn_cont (self, struct nn_stcp, fsm); switch (stcp->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_STCP_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_streamhdr_start (&stcp->streamhdr, stcp->usock, &stcp->pipebase); stcp->state = NN_STCP_STATE_PROTOHDR; return; default: nn_fsm_bad_action (stcp->state, src, type); } default: nn_fsm_bad_source (stcp->state, src, type); } /******************************************************************************/ /* PROTOHDR state. */ /******************************************************************************/ case NN_STCP_STATE_PROTOHDR: switch (src) { case NN_STCP_SRC_STREAMHDR: switch (type) { case NN_STREAMHDR_OK: /* Before moving to the active state stop the streamhdr state machine. */ nn_streamhdr_stop (&stcp->streamhdr); stcp->state = NN_STCP_STATE_STOPPING_STREAMHDR; return; case NN_STREAMHDR_ERROR: /* Raise the error and move directly to the DONE state. streamhdr object will be stopped later on. */ stcp->state = NN_STCP_STATE_DONE; nn_fsm_raise (&stcp->fsm, &stcp->done, NN_STCP_ERROR); return; default: nn_fsm_bad_action (stcp->state, src, type); } default: nn_fsm_bad_source (stcp->state, src, type); } /******************************************************************************/ /* STOPPING_STREAMHDR state. */ /******************************************************************************/ case NN_STCP_STATE_STOPPING_STREAMHDR: switch (src) { case NN_STCP_SRC_STREAMHDR: switch (type) { case NN_STREAMHDR_STOPPED: /* Start the pipe. */ rc = nn_pipebase_start (&stcp->pipebase); if (nn_slow (rc < 0)) { stcp->state = NN_STCP_STATE_DONE; nn_fsm_raise (&stcp->fsm, &stcp->done, NN_STCP_ERROR); return; } /* Start receiving a message in asynchronous manner. */ stcp->instate = NN_STCP_INSTATE_HDR; nn_usock_recv (stcp->usock, &stcp->inhdr, sizeof (stcp->inhdr), NULL); /* Mark the pipe as available for sending. */ stcp->outstate = NN_STCP_OUTSTATE_IDLE; stcp->state = NN_STCP_STATE_ACTIVE; return; default: nn_fsm_bad_action (stcp->state, src, type); } default: nn_fsm_bad_source (stcp->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /******************************************************************************/ case NN_STCP_STATE_ACTIVE: switch (src) { case NN_STCP_SRC_USOCK: switch (type) { case NN_USOCK_SENT: /* The message is now fully sent. */ nn_assert (stcp->outstate == NN_STCP_OUTSTATE_SENDING); stcp->outstate = NN_STCP_OUTSTATE_IDLE; nn_msg_term (&stcp->outmsg); nn_msg_init (&stcp->outmsg, 0); nn_pipebase_sent (&stcp->pipebase); return; case NN_USOCK_RECEIVED: switch (stcp->instate) { case NN_STCP_INSTATE_HDR: /* Message header was received. Check that message size is acceptable by comparing with NN_RCVMAXSIZE; if it's too large, drop the connection. */ size = nn_getll (stcp->inhdr); nn_pipebase_getopt (&stcp->pipebase, NN_SOL_SOCKET, NN_RCVMAXSIZE, &opt, &opt_sz); if (opt >= 0 && size > (unsigned)opt) { stcp->state = NN_STCP_STATE_DONE; nn_fsm_raise (&stcp->fsm, &stcp->done, NN_STCP_ERROR); return; } /* Allocate memory for the message. */ nn_msg_term (&stcp->inmsg); nn_msg_init (&stcp->inmsg, (size_t) size); /* Special case when size of the message body is 0. */ if (!size) { stcp->instate = NN_STCP_INSTATE_HASMSG; nn_pipebase_received (&stcp->pipebase); return; } /* Start receiving the message body. */ stcp->instate = NN_STCP_INSTATE_BODY; nn_usock_recv (stcp->usock, nn_chunkref_data (&stcp->inmsg.body), (size_t) size, NULL); return; case NN_STCP_INSTATE_BODY: /* Message body was received. Notify the owner that it can receive it. */ stcp->instate = NN_STCP_INSTATE_HASMSG; nn_pipebase_received (&stcp->pipebase); return; default: nn_fsm_error("Unexpected socket instate", stcp->state, src, type); } case NN_USOCK_SHUTDOWN: nn_pipebase_stop (&stcp->pipebase); stcp->state = NN_STCP_STATE_SHUTTING_DOWN; return; case NN_USOCK_ERROR: nn_pipebase_stop (&stcp->pipebase); stcp->state = NN_STCP_STATE_DONE; nn_fsm_raise (&stcp->fsm, &stcp->done, NN_STCP_ERROR); return; default: nn_fsm_bad_action (stcp->state, src, type); } default: nn_fsm_bad_source (stcp->state, src, type); } /******************************************************************************/ /* SHUTTING_DOWN state. */ /* The underlying connection is closed. We are just waiting that underlying */ /* usock being closed */ /******************************************************************************/ case NN_STCP_STATE_SHUTTING_DOWN: switch (src) { case NN_STCP_SRC_USOCK: switch (type) { case NN_USOCK_ERROR: stcp->state = NN_STCP_STATE_DONE; nn_fsm_raise (&stcp->fsm, &stcp->done, NN_STCP_ERROR); return; default: nn_fsm_bad_action (stcp->state, src, type); } default: nn_fsm_bad_source (stcp->state, src, type); } /******************************************************************************/ /* DONE state. */ /* The underlying connection is closed. There's nothing that can be done in */ /* this state except stopping the object. */ /******************************************************************************/ case NN_STCP_STATE_DONE: nn_fsm_bad_source (stcp->state, src, type); /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (stcp->state, src, type); } } nanomsg-0.8-beta/src/transports/tcp/tcp.h0000664000175000017500000000237712623652600021406 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_TCP_INCLUDED #define NN_TCP_INCLUDED #include "../../transport.h" extern struct nn_transport *nn_tcp; #endif nanomsg-0.8-beta/src/transports/tcp/tcp.c0000664000175000017500000001046412623652600021375 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "tcp.h" #include "btcp.h" #include "ctcp.h" #include "../../tcp.h" #include "../utils/port.h" #include "../utils/iface.h" #include "../../utils/err.h" #include "../../utils/alloc.h" #include "../../utils/fast.h" #include "../../utils/list.h" #include "../../utils/cont.h" #include #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #endif /* TCP-specific socket options. */ struct nn_tcp_optset { struct nn_optset base; int nodelay; }; static void nn_tcp_optset_destroy (struct nn_optset *self); static int nn_tcp_optset_setopt (struct nn_optset *self, int option, const void *optval, size_t optvallen); static int nn_tcp_optset_getopt (struct nn_optset *self, int option, void *optval, size_t *optvallen); static const struct nn_optset_vfptr nn_tcp_optset_vfptr = { nn_tcp_optset_destroy, nn_tcp_optset_setopt, nn_tcp_optset_getopt }; /* nn_transport interface. */ static int nn_tcp_bind (void *hint, struct nn_epbase **epbase); static int nn_tcp_connect (void *hint, struct nn_epbase **epbase); static struct nn_optset *nn_tcp_optset (void); static struct nn_transport nn_tcp_vfptr = { "tcp", NN_TCP, NULL, NULL, nn_tcp_bind, nn_tcp_connect, nn_tcp_optset, NN_LIST_ITEM_INITIALIZER }; struct nn_transport *nn_tcp = &nn_tcp_vfptr; static int nn_tcp_bind (void *hint, struct nn_epbase **epbase) { return nn_btcp_create (hint, epbase); } static int nn_tcp_connect (void *hint, struct nn_epbase **epbase) { return nn_ctcp_create (hint, epbase); } static struct nn_optset *nn_tcp_optset () { struct nn_tcp_optset *optset; optset = nn_alloc (sizeof (struct nn_tcp_optset), "optset (tcp)"); alloc_assert (optset); optset->base.vfptr = &nn_tcp_optset_vfptr; /* Default values for TCP socket options. */ optset->nodelay = 0; return &optset->base; } static void nn_tcp_optset_destroy (struct nn_optset *self) { struct nn_tcp_optset *optset; optset = nn_cont (self, struct nn_tcp_optset, base); nn_free (optset); } static int nn_tcp_optset_setopt (struct nn_optset *self, int option, const void *optval, size_t optvallen) { struct nn_tcp_optset *optset; int val; optset = nn_cont (self, struct nn_tcp_optset, base); /* At this point we assume that all options are of type int. */ if (optvallen != sizeof (int)) return -EINVAL; val = *(int*) optval; switch (option) { case NN_TCP_NODELAY: if (nn_slow (val != 0 && val != 1)) return -EINVAL; optset->nodelay = val; return 0; default: return -ENOPROTOOPT; } } static int nn_tcp_optset_getopt (struct nn_optset *self, int option, void *optval, size_t *optvallen) { struct nn_tcp_optset *optset; int intval; optset = nn_cont (self, struct nn_tcp_optset, base); switch (option) { case NN_TCP_NODELAY: intval = optset->nodelay; break; default: return -ENOPROTOOPT; } memcpy (optval, &intval, *optvallen < sizeof (int) ? *optvallen : sizeof (int)); *optvallen = sizeof (int); return 0; } nanomsg-0.8-beta/src/transports/tcpmux/0000775000175000017500000000000012623652617021200 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/transports/tcpmux/atcpmux.h0000664000175000017500000000505012623652600023022 0ustar00travistravis00000000000000/* Copyright (c) 2013-2014 Martin Sustrik 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. */ #ifndef NN_ATCPMUX_INCLUDED #define NN_ATCPMUX_INCLUDED #include "stcpmux.h" #include "../../transport.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../../utils/list.h" /* State machine handling accepted TCPMUX sockets. */ /* In btcpmux, some events are just *assumed* to come from a child atcpmux object. By using non-trivial event codes, we can do more reliable sanity checking in such scenarios. */ #define NN_ATCPMUX_ACCEPTED 34231 #define NN_ATCPMUX_ERROR 34232 #define NN_ATCPMUX_STOPPED 34233 struct nn_atcpmux { /* The state machine. */ struct nn_fsm fsm; int state; /* Pointer to the associated endpoint. */ struct nn_epbase *epbase; /* Underlying socket. */ struct nn_usock usock; /* State machine that takes care of the connection in the active state. */ struct nn_stcpmux stcpmux; /* Events generated by atcpmux state machine. */ struct nn_fsm_event accepted; struct nn_fsm_event done; /* This member can be used by owner to keep individual atcpmuxes in a list. */ struct nn_list_item item; }; void nn_atcpmux_init (struct nn_atcpmux *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner); void nn_atcpmux_term (struct nn_atcpmux *self); int nn_atcpmux_isidle (struct nn_atcpmux *self); void nn_atcpmux_start (struct nn_atcpmux *self, int fd); void nn_atcpmux_stop (struct nn_atcpmux *self); #endif nanomsg-0.8-beta/src/transports/tcpmux/atcpmux.c0000664000175000017500000001762612623652600023031 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik 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 "atcpmux.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/attr.h" #define NN_ATCPMUX_STATE_IDLE 1 #define NN_ATCPMUX_STATE_ACTIVE 2 #define NN_ATCPMUX_STATE_STOPPING_STCPMUX 3 #define NN_ATCPMUX_STATE_STOPPING_USOCK 4 #define NN_ATCPMUX_STATE_DONE 5 #define NN_ATCPMUX_STATE_STOPPING_STCPMUX_FINAL 6 #define NN_ATCPMUX_STATE_STOPPING 7 #define NN_ATCPMUX_SRC_USOCK 1 #define NN_ATCPMUX_SRC_STCPMUX 2 /* Private functions. */ static void nn_atcpmux_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_atcpmux_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); void nn_atcpmux_init (struct nn_atcpmux *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_atcpmux_handler, nn_atcpmux_shutdown, src, self, owner); self->state = NN_ATCPMUX_STATE_IDLE; self->epbase = epbase; nn_usock_init (&self->usock, NN_ATCPMUX_SRC_USOCK, &self->fsm); nn_stcpmux_init (&self->stcpmux, NN_ATCPMUX_SRC_STCPMUX, epbase, &self->fsm); nn_fsm_event_init (&self->accepted); nn_fsm_event_init (&self->done); nn_list_item_init (&self->item); } void nn_atcpmux_term (struct nn_atcpmux *self) { nn_assert_state (self, NN_ATCPMUX_STATE_IDLE); nn_list_item_term (&self->item); nn_fsm_event_term (&self->done); nn_fsm_event_term (&self->accepted); nn_stcpmux_term (&self->stcpmux); nn_usock_term (&self->usock); nn_fsm_term (&self->fsm); } int nn_atcpmux_isidle (struct nn_atcpmux *self) { return nn_fsm_isidle (&self->fsm); } void nn_atcpmux_start (struct nn_atcpmux *self, int fd) { nn_assert_state (self, NN_ATCPMUX_STATE_IDLE); /* Start the state machine. */ nn_fsm_start (&self->fsm); /* Start the stcp state machine. */ nn_usock_start_fd (&self->usock, fd); nn_stcpmux_start (&self->stcpmux, &self->usock); self->state = NN_ATCPMUX_STATE_ACTIVE; } void nn_atcpmux_stop (struct nn_atcpmux *self) { nn_fsm_stop (&self->fsm); } static void nn_atcpmux_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_atcpmux *atcpmux; atcpmux = nn_cont (self, struct nn_atcpmux, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { if (!nn_stcpmux_isidle (&atcpmux->stcpmux)) { nn_epbase_stat_increment (atcpmux->epbase, NN_STAT_DROPPED_CONNECTIONS, 1); nn_stcpmux_stop (&atcpmux->stcpmux); } atcpmux->state = NN_ATCPMUX_STATE_STOPPING_STCPMUX_FINAL; } if (nn_slow (atcpmux->state == NN_ATCPMUX_STATE_STOPPING_STCPMUX_FINAL)) { if (!nn_stcpmux_isidle (&atcpmux->stcpmux)) return; nn_usock_stop (&atcpmux->usock); atcpmux->state = NN_ATCPMUX_STATE_STOPPING; } if (nn_slow (atcpmux->state == NN_ATCPMUX_STATE_STOPPING)) { if (!nn_usock_isidle (&atcpmux->usock)) return; atcpmux->state = NN_ATCPMUX_STATE_IDLE; nn_fsm_stopped (&atcpmux->fsm, NN_ATCPMUX_STOPPED); return; } nn_fsm_bad_action(atcpmux->state, src, type); } static void nn_atcpmux_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_atcpmux *atcpmux; atcpmux = nn_cont (self, struct nn_atcpmux, fsm); switch (atcpmux->state) { /******************************************************************************/ /* IDLE state. */ /* The state machine wasn't yet started. */ /******************************************************************************/ case NN_ATCPMUX_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: // TODO atcpmux->state = NN_ATCPMUX_STATE_ACTIVE; return; default: nn_fsm_bad_action (atcpmux->state, src, type); } default: nn_fsm_bad_source (atcpmux->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /******************************************************************************/ case NN_ATCPMUX_STATE_ACTIVE: switch (src) { case NN_ATCPMUX_SRC_STCPMUX: switch (type) { case NN_STCPMUX_ERROR: nn_stcpmux_stop (&atcpmux->stcpmux); atcpmux->state = NN_ATCPMUX_STATE_STOPPING_STCPMUX; nn_epbase_stat_increment (atcpmux->epbase, NN_STAT_BROKEN_CONNECTIONS, 1); return; default: nn_fsm_bad_action (atcpmux->state, src, type); } default: nn_fsm_bad_source (atcpmux->state, src, type); } /******************************************************************************/ /* STOPPING_STCPMUX state. */ /******************************************************************************/ case NN_ATCPMUX_STATE_STOPPING_STCPMUX: switch (src) { case NN_ATCPMUX_SRC_STCPMUX: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_STCPMUX_STOPPED: nn_usock_stop (&atcpmux->usock); atcpmux->state = NN_ATCPMUX_STATE_STOPPING_USOCK; return; default: nn_fsm_bad_action (atcpmux->state, src, type); } default: nn_fsm_bad_source (atcpmux->state, src, type); } /******************************************************************************/ /* STOPPING_USOCK state. */ /******************************************************************************/ case NN_ATCPMUX_STATE_STOPPING_USOCK: switch (src) { case NN_ATCPMUX_SRC_USOCK: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_USOCK_STOPPED: nn_fsm_raise (&atcpmux->fsm, &atcpmux->done, NN_ATCPMUX_ERROR); atcpmux->state = NN_ATCPMUX_STATE_DONE; return; default: nn_fsm_bad_action (atcpmux->state, src, type); } default: nn_fsm_bad_source (atcpmux->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (atcpmux->state, src, type); } } nanomsg-0.8-beta/src/transports/tcpmux/btcpmux.h0000664000175000017500000000252712623652600023031 0ustar00travistravis00000000000000/* Copyright (c) 2013-2014 Martin Sustrik 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. */ #ifndef NN_BTCPMUX_INCLUDED #define NN_BTCPMUX_INCLUDED #include "../../transport.h" /* State machine managing bound TCPMUX socket. */ int nn_btcpmux_create (void *hint, struct nn_epbase **epbase); #endif nanomsg-0.8-beta/src/transports/tcpmux/btcpmux.c0000664000175000017500000004241112623652600023020 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik 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 "btcpmux.h" #include "atcpmux.h" #include "../utils/port.h" #include "../utils/iface.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../utils/backoff.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/alloc.h" #include "../../utils/list.h" #include "../../utils/fast.h" #include "../../utils/int.h" #include #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #include #include #endif /* The backlog is set relatively high so that there are not too many failed connection attemps during re-connection storms. */ #define NN_BTCPMUX_BACKLOG 100 #define NN_BTCPMUX_STATE_IDLE 1 #define NN_BTCPMUX_STATE_CONNECTING 2 #define NN_BTCPMUX_STATE_SENDING_BINDREQ 3 #define NN_BTCPMUX_STATE_ACTIVE 4 #define NN_BTCPMUX_STATE_STOPPING_USOCK 5 #define NN_BTCPMUX_STATE_STOPPING_ATCPMUXES 6 #define NN_BTCPMUX_STATE_LISTENING 7 #define NN_BTCPMUX_STATE_WAITING 8 #define NN_BTCPMUX_STATE_CLOSING 9 #define NN_BTCPMUX_STATE_STOPPING_BACKOFF 10 #define NN_BTCPMUX_SRC_USOCK 1 #define NN_BTCPMUX_SRC_ATCPMUX 2 #define NN_BTCPMUX_SRC_RECONNECT_TIMER 3 struct nn_btcpmux { /* The state machine. */ struct nn_fsm fsm; int state; /* This object is a specific type of endpoint. Thus it is derived from epbase. */ struct nn_epbase epbase; /* The underlying listening TCPMUX socket. */ struct nn_usock usock; /* List of accepted connections. */ struct nn_list atcpmuxes; /* Used to wait before retrying to connect. */ struct nn_backoff retry; /* Service name. */ const char *service; /* Service name length, in network byte order. */ uint16_t servicelen; /* File descriptor of newly accepted connection. */ int newfd; /* Temporary buffer. */ char code; }; /* nn_epbase virtual interface implementation. */ static void nn_btcpmux_stop (struct nn_epbase *self); static void nn_btcpmux_destroy (struct nn_epbase *self); const struct nn_epbase_vfptr nn_btcpmux_epbase_vfptr = { nn_btcpmux_stop, nn_btcpmux_destroy }; /* Private functions. */ static void nn_btcpmux_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_btcpmux_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_btcpmux_start_connecting (struct nn_btcpmux *self); int nn_btcpmux_create (void *hint, struct nn_epbase **epbase) { int rc; struct nn_btcpmux *self; const char *addr; const char *colon; const char *slash; const char *end; int reconnect_ivl; int reconnect_ivl_max; size_t sz; /* Allocate the new endpoint object. */ self = nn_alloc (sizeof (struct nn_btcpmux), "btcpmux"); alloc_assert (self); /* Initalise the epbase. */ nn_epbase_init (&self->epbase, &nn_btcpmux_epbase_vfptr, hint); /* Parse the connection string. For now, we can only bind to all interfaces. */ addr = nn_epbase_getaddr (&self->epbase); colon = strchr (addr, ':'); if (nn_slow (!colon || colon - addr != 1 || addr [0] != '*')) { nn_epbase_term (&self->epbase); return -EINVAL; } slash = strchr (colon + 1, '/'); if (nn_slow (!slash)) { nn_epbase_term (&self->epbase); return -EINVAL; } end = addr + strlen (addr); /* Parse the port. */ rc = nn_port_resolve (colon + 1, slash - (colon + 1)); if (nn_slow (rc < 0)) { nn_epbase_term (&self->epbase); return -EINVAL; } /* Store the service name. */ self->service = slash + 1; self->servicelen = htons (end - (slash + 1)); /* Initialise the structure. */ nn_fsm_init_root (&self->fsm, nn_btcpmux_handler, nn_btcpmux_shutdown, nn_epbase_getctx (&self->epbase)); self->state = NN_BTCPMUX_STATE_IDLE; sz = sizeof (reconnect_ivl); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL, &reconnect_ivl, &sz); nn_assert (sz == sizeof (reconnect_ivl)); sz = sizeof (reconnect_ivl_max); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL_MAX, &reconnect_ivl_max, &sz); nn_assert (sz == sizeof (reconnect_ivl_max)); if (reconnect_ivl_max == 0) reconnect_ivl_max = reconnect_ivl; nn_backoff_init (&self->retry, NN_BTCPMUX_SRC_RECONNECT_TIMER, reconnect_ivl, reconnect_ivl_max, &self->fsm); nn_usock_init (&self->usock, NN_BTCPMUX_SRC_USOCK, &self->fsm); nn_list_init (&self->atcpmuxes); /* Start the state machine. */ nn_fsm_start (&self->fsm); /* Return the base class as an out parameter. */ *epbase = &self->epbase; return 0; } static void nn_btcpmux_stop (struct nn_epbase *self) { struct nn_btcpmux *btcpmux; btcpmux = nn_cont (self, struct nn_btcpmux, epbase); nn_fsm_stop (&btcpmux->fsm); } static void nn_btcpmux_destroy (struct nn_epbase *self) { struct nn_btcpmux *btcpmux; btcpmux = nn_cont (self, struct nn_btcpmux, epbase); nn_assert_state (btcpmux, NN_BTCPMUX_STATE_IDLE); nn_list_term (&btcpmux->atcpmuxes); nn_usock_term (&btcpmux->usock); nn_backoff_term (&btcpmux->retry); nn_epbase_term (&btcpmux->epbase); nn_fsm_term (&btcpmux->fsm); nn_free (btcpmux); } static void nn_btcpmux_shutdown (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_btcpmux *btcpmux; struct nn_list_item *it; struct nn_atcpmux *atcpmux; btcpmux = nn_cont (self, struct nn_btcpmux, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { nn_backoff_stop (&btcpmux->retry); nn_usock_stop (&btcpmux->usock); btcpmux->state = NN_BTCPMUX_STATE_STOPPING_USOCK; } if (nn_slow (btcpmux->state == NN_BTCPMUX_STATE_STOPPING_USOCK)) { if (!nn_usock_isidle (&btcpmux->usock)) return; for (it = nn_list_begin (&btcpmux->atcpmuxes); it != nn_list_end (&btcpmux->atcpmuxes); it = nn_list_next (&btcpmux->atcpmuxes, it)) { atcpmux = nn_cont (it, struct nn_atcpmux, item); nn_atcpmux_stop (atcpmux); } btcpmux->state = NN_BTCPMUX_STATE_STOPPING_ATCPMUXES; goto atcpmuxes_stopping; } if (nn_slow (btcpmux->state == NN_BTCPMUX_STATE_STOPPING_ATCPMUXES)) { nn_assert (src == NN_BTCPMUX_SRC_ATCPMUX && type == NN_ATCPMUX_STOPPED); atcpmux = (struct nn_atcpmux *) srcptr; nn_list_erase (&btcpmux->atcpmuxes, &atcpmux->item); nn_atcpmux_term (atcpmux); nn_free (atcpmux); /* If there are no more atcpmux state machines, we can stop the whole btcpmux object. */ atcpmuxes_stopping: if (nn_list_empty (&btcpmux->atcpmuxes)) { btcpmux->state = NN_BTCPMUX_STATE_IDLE; nn_fsm_stopped_noevent (&btcpmux->fsm); nn_epbase_stopped (&btcpmux->epbase); return; } return; } nn_fsm_bad_action(btcpmux->state, src, type); } static void nn_btcpmux_handler (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_btcpmux *btcpmux; struct nn_atcpmux *atcpmux; struct nn_iovec iovecs [2]; btcpmux = nn_cont (self, struct nn_btcpmux, fsm); switch (btcpmux->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_BTCPMUX_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_btcpmux_start_connecting (btcpmux); return; default: nn_fsm_bad_action (btcpmux->state, src, type); } default: nn_fsm_bad_source (btcpmux->state, src, type); } /******************************************************************************/ /* CONNECTING state. */ /******************************************************************************/ case NN_BTCPMUX_STATE_CONNECTING: switch (src) { case NN_BTCPMUX_SRC_USOCK: switch (type) { case NN_USOCK_CONNECTED: iovecs [0].iov_base = &btcpmux->servicelen; iovecs [0].iov_len = 2; iovecs [1].iov_base = (void*) btcpmux->service; iovecs [1].iov_len = ntohs (btcpmux->servicelen); nn_usock_send (&btcpmux->usock, iovecs, 2); btcpmux->state = NN_BTCPMUX_STATE_SENDING_BINDREQ; return; case NN_USOCK_ERROR: nn_usock_stop (&btcpmux->usock); btcpmux->state = NN_BTCPMUX_STATE_STOPPING_USOCK; return; default: nn_fsm_bad_action (btcpmux->state, src, type); } default: nn_fsm_bad_source (btcpmux->state, src, type); } /******************************************************************************/ /* SENDING_BINDREQ state. */ /******************************************************************************/ case NN_BTCPMUX_STATE_SENDING_BINDREQ: switch (src) { case NN_BTCPMUX_SRC_USOCK: switch (type) { case NN_USOCK_SENT: nn_usock_recv (&btcpmux->usock, &btcpmux->code, 1, &btcpmux->newfd); btcpmux->state = NN_BTCPMUX_STATE_ACTIVE; return; case NN_USOCK_ERROR: nn_usock_stop (&btcpmux->usock); btcpmux->state = NN_BTCPMUX_STATE_STOPPING_USOCK; return; default: nn_fsm_bad_action (btcpmux->state, src, type); } default: nn_fsm_bad_source (btcpmux->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /* The execution is yielded to the atcpmux state machine in this state. */ /******************************************************************************/ case NN_BTCPMUX_STATE_ACTIVE: if (src == NN_BTCPMUX_SRC_USOCK) { switch (type) { case NN_USOCK_RECEIVED: if (btcpmux->code != 0 || btcpmux->newfd < 0) { nn_usock_stop (&btcpmux->usock); btcpmux->state = NN_BTCPMUX_STATE_STOPPING_USOCK; return; } /* Allocate new atcpmux state machine. */ atcpmux = nn_alloc (sizeof (struct nn_atcpmux), "atcpmux"); alloc_assert (atcpmux); nn_atcpmux_init (atcpmux, NN_BTCPMUX_SRC_ATCPMUX, &btcpmux->epbase, &btcpmux->fsm); nn_atcpmux_start (atcpmux, btcpmux->newfd); nn_list_insert (&btcpmux->atcpmuxes, &atcpmux->item, nn_list_end (&btcpmux->atcpmuxes)); /* Start accepting new connection straight away. */ nn_usock_recv (&btcpmux->usock, &btcpmux->code, 1, &btcpmux->newfd); return; case NN_USOCK_ERROR: nn_usock_stop (&btcpmux->usock); btcpmux->state = NN_BTCPMUX_STATE_STOPPING_USOCK; return; default: nn_fsm_bad_action (btcpmux->state, src, type); } } /* For all remaining events we'll assume they are coming from one of remaining child atcpmux objects. */ nn_assert (src == NN_BTCPMUX_SRC_ATCPMUX); atcpmux = (struct nn_atcpmux*) srcptr; switch (type) { case NN_ATCPMUX_ERROR: nn_atcpmux_stop (atcpmux); return; case NN_ATCPMUX_STOPPED: nn_list_erase (&btcpmux->atcpmuxes, &atcpmux->item); nn_atcpmux_term (atcpmux); nn_free (atcpmux); return; default: nn_fsm_bad_action (btcpmux->state, src, type); } /******************************************************************************/ /* CLOSING_USOCK state. */ /* usock object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_BTCPMUX_STATE_CLOSING: switch (src) { case NN_BTCPMUX_SRC_USOCK: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_USOCK_STOPPED: nn_backoff_start (&btcpmux->retry); btcpmux->state = NN_BTCPMUX_STATE_WAITING; return; default: nn_fsm_bad_action (btcpmux->state, src, type); } default: nn_fsm_bad_source (btcpmux->state, src, type); } /******************************************************************************/ /* WAITING state. */ /* Waiting before re-bind is attempted. This way we won't overload */ /* the system by continuous re-bind attemps. */ /******************************************************************************/ case NN_BTCPMUX_STATE_WAITING: switch (src) { case NN_BTCPMUX_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_TIMEOUT: nn_backoff_stop (&btcpmux->retry); btcpmux->state = NN_BTCPMUX_STATE_STOPPING_BACKOFF; return; default: nn_fsm_bad_action (btcpmux->state, src, type); } default: nn_fsm_bad_source (btcpmux->state, src, type); } /******************************************************************************/ /* STOPPING_BACKOFF state. */ /* backoff object was asked to stop, but it haven't stopped yet. */ /******************************************************************************/ case NN_BTCPMUX_STATE_STOPPING_BACKOFF: switch (src) { case NN_BTCPMUX_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_STOPPED: nn_btcpmux_start_connecting (btcpmux); return; default: nn_fsm_bad_action (btcpmux->state, src, type); } default: nn_fsm_bad_source (btcpmux->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (btcpmux->state, src, type); } } /******************************************************************************/ /* State machine actions. */ /******************************************************************************/ static void nn_btcpmux_start_connecting (struct nn_btcpmux *self) { int rc; struct sockaddr_storage ss; struct sockaddr_un *un; const char *addr; const char *colon; const char *slash; int port; /* Try to start the underlying socket. */ rc = nn_usock_start (&self->usock, AF_UNIX, SOCK_STREAM, 0); if (nn_slow (rc < 0)) { nn_backoff_start (&self->retry); self->state = NN_BTCPMUX_STATE_WAITING; return; } /* Create the IPC address from the address string. */ addr = nn_epbase_getaddr (&self->epbase); colon = strchr (addr, ':'); slash = strchr (colon + 1, '/'); port = nn_port_resolve (colon + 1, slash - (colon + 1)); memset (&ss, 0, sizeof (ss)); un = (struct sockaddr_un*) &ss; ss.ss_family = AF_UNIX; sprintf (un->sun_path, "/tmp/tcpmux-%d.ipc", (int) port); /* Start connecting. */ nn_usock_connect (&self->usock, (struct sockaddr*) &ss, sizeof (struct sockaddr_un)); self->state = NN_BTCPMUX_STATE_CONNECTING; } nanomsg-0.8-beta/src/transports/tcpmux/ctcpmux.h0000664000175000017500000000253312623652600023027 0ustar00travistravis00000000000000/* Copyright (c) 2013-2014 Martin Sustrik 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. */ #ifndef NN_CTCPMUX_INCLUDED #define NN_CTCPMUX_INCLUDED #include "../../transport.h" /* State machine managing connected TCPMUX socket. */ int nn_ctcpmux_create (void *hint, struct nn_epbase **epbase); #endif nanomsg-0.8-beta/src/transports/tcpmux/ctcpmux.c0000664000175000017500000006105612623652600023027 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik 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 "ctcpmux.h" #include "stcpmux.h" #include "../../tcpmux.h" #include "../utils/dns.h" #include "../utils/port.h" #include "../utils/iface.h" #include "../utils/backoff.h" #include "../utils/literal.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/alloc.h" #include "../../utils/fast.h" #include "../../utils/int.h" #include "../../utils/attr.h" #include #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #include #include #endif #define NN_CTCPMUX_STATE_IDLE 1 #define NN_CTCPMUX_STATE_RESOLVING 2 #define NN_CTCPMUX_STATE_STOPPING_DNS 3 #define NN_CTCPMUX_STATE_CONNECTING 4 #define NN_CTCPMUX_STATE_SENDING_TCPMUXHDR 5 #define NN_CTCPMUX_STATE_RECEIVING_TCPMUXHDR 6 #define NN_CTCPMUX_STATE_ACTIVE 7 #define NN_CTCPMUX_STATE_STOPPING_STCPMUX 8 #define NN_CTCPMUX_STATE_STOPPING_USOCK 9 #define NN_CTCPMUX_STATE_WAITING 10 #define NN_CTCPMUX_STATE_STOPPING_BACKOFF 11 #define NN_CTCPMUX_STATE_STOPPING_STCPMUX_FINAL 12 #define NN_CTCPMUX_STATE_STOPPING 13 #define NN_CTCPMUX_SRC_USOCK 1 #define NN_CTCPMUX_SRC_RECONNECT_TIMER 2 #define NN_CTCPMUX_SRC_DNS 3 #define NN_CTCPMUX_SRC_STCPMUX 4 struct nn_ctcpmux { /* The state machine. */ struct nn_fsm fsm; int state; /* This object is a specific type of endpoint. Thus it is derived from epbase. */ struct nn_epbase epbase; /* The underlying TCPMUX socket. */ struct nn_usock usock; /* Used to wait before retrying to connect. */ struct nn_backoff retry; /* State machine that handles the active part of the connection lifetime. */ struct nn_stcpmux stcpmux; /* DNS resolver used to convert textual address into actual IP address along with the variable to hold the result. */ struct nn_dns dns; struct nn_dns_result dns_result; /* Buffer used in TCPMUX header exchange. */ char buffer [256]; }; /* nn_epbase virtual interface implementation. */ static void nn_ctcpmux_stop (struct nn_epbase *self); static void nn_ctcpmux_destroy (struct nn_epbase *self); const struct nn_epbase_vfptr nn_ctcpmux_epbase_vfptr = { nn_ctcpmux_stop, nn_ctcpmux_destroy }; /* Private functions. */ static void nn_ctcpmux_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_ctcpmux_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_ctcpmux_start_resolving (struct nn_ctcpmux *self); static void nn_ctcpmux_start_connecting (struct nn_ctcpmux *self, struct sockaddr_storage *ss, size_t sslen); int nn_ctcpmux_create (void *hint, struct nn_epbase **epbase) { int rc; const char *addr; size_t addrlen; const char *semicolon; const char *hostname; const char *colon; const char *slash; const char *end; struct sockaddr_storage ss; size_t sslen; int ipv4only; size_t ipv4onlylen; struct nn_ctcpmux *self; int reconnect_ivl; int reconnect_ivl_max; size_t sz; /* Allocate the new endpoint object. */ self = nn_alloc (sizeof (struct nn_ctcpmux), "ctcpmux"); alloc_assert (self); /* Initalise the endpoint. */ nn_epbase_init (&self->epbase, &nn_ctcpmux_epbase_vfptr, hint); /* Check whether IPv6 is to be used. */ ipv4onlylen = sizeof (ipv4only); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY, &ipv4only, &ipv4onlylen); nn_assert (ipv4onlylen == sizeof (ipv4only)); /* Start parsing the address. */ addr = nn_epbase_getaddr (&self->epbase); addrlen = strlen (addr); semicolon = strchr (addr, ';'); hostname = semicolon != NULL ? semicolon + 1 : addr; colon = strrchr (addr, ':'); if (colon != NULL) { slash = strchr (colon + 1, '/'); } else { slash = NULL; } end = addr + addrlen; if (nn_slow (!colon || !slash || (size_t)(end - (slash + 1)) > sizeof (self->buffer) - 3)) { nn_epbase_term (&self->epbase); return -EINVAL; } /* Parse the port. */ rc = nn_port_resolve (colon + 1, slash - colon - 1); if (nn_slow (rc < 0)) { nn_epbase_term (&self->epbase); return -EINVAL; } /* Check whether the host portion of the address is either a literal or a valid hostname. */ if (nn_dns_check_hostname (hostname, colon - hostname) < 0 && nn_literal_resolve (hostname, colon - hostname, ipv4only, &ss, &sslen) < 0) { nn_epbase_term (&self->epbase); return -EINVAL; } /* If local address is specified, check whether it is valid. */ if (semicolon) { rc = nn_iface_resolve (addr, semicolon - addr, ipv4only, &ss, &sslen); if (rc < 0) { nn_epbase_term (&self->epbase); return -ENODEV; } } /* Initialise the structure. */ nn_fsm_init_root (&self->fsm, nn_ctcpmux_handler, nn_ctcpmux_shutdown, nn_epbase_getctx (&self->epbase)); self->state = NN_CTCPMUX_STATE_IDLE; nn_usock_init (&self->usock, NN_CTCPMUX_SRC_USOCK, &self->fsm); sz = sizeof (reconnect_ivl); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL, &reconnect_ivl, &sz); nn_assert (sz == sizeof (reconnect_ivl)); sz = sizeof (reconnect_ivl_max); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL_MAX, &reconnect_ivl_max, &sz); nn_assert (sz == sizeof (reconnect_ivl_max)); if (reconnect_ivl_max == 0) reconnect_ivl_max = reconnect_ivl; nn_backoff_init (&self->retry, NN_CTCPMUX_SRC_RECONNECT_TIMER, reconnect_ivl, reconnect_ivl_max, &self->fsm); nn_stcpmux_init (&self->stcpmux, NN_CTCPMUX_SRC_STCPMUX, &self->epbase, &self->fsm); nn_dns_init (&self->dns, NN_CTCPMUX_SRC_DNS, &self->fsm); /* Start the state machine. */ nn_fsm_start (&self->fsm); /* Return the base class as an out parameter. */ *epbase = &self->epbase; return 0; } static void nn_ctcpmux_stop (struct nn_epbase *self) { struct nn_ctcpmux *ctcpmux; ctcpmux = nn_cont (self, struct nn_ctcpmux, epbase); nn_fsm_stop (&ctcpmux->fsm); } static void nn_ctcpmux_destroy (struct nn_epbase *self) { struct nn_ctcpmux *ctcpmux; ctcpmux = nn_cont (self, struct nn_ctcpmux, epbase); nn_dns_term (&ctcpmux->dns); nn_stcpmux_term (&ctcpmux->stcpmux); nn_backoff_term (&ctcpmux->retry); nn_usock_term (&ctcpmux->usock); nn_fsm_term (&ctcpmux->fsm); nn_epbase_term (&ctcpmux->epbase); nn_free (ctcpmux); } static void nn_ctcpmux_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_ctcpmux *ctcpmux; ctcpmux = nn_cont (self, struct nn_ctcpmux, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { if (!nn_stcpmux_isidle (&ctcpmux->stcpmux)) { nn_epbase_stat_increment (&ctcpmux->epbase, NN_STAT_DROPPED_CONNECTIONS, 1); nn_stcpmux_stop (&ctcpmux->stcpmux); } ctcpmux->state = NN_CTCPMUX_STATE_STOPPING_STCPMUX_FINAL; } if (nn_slow (ctcpmux->state == NN_CTCPMUX_STATE_STOPPING_STCPMUX_FINAL)) { if (!nn_stcpmux_isidle (&ctcpmux->stcpmux)) return; nn_backoff_stop (&ctcpmux->retry); nn_usock_stop (&ctcpmux->usock); nn_dns_stop (&ctcpmux->dns); ctcpmux->state = NN_CTCPMUX_STATE_STOPPING; } if (nn_slow (ctcpmux->state == NN_CTCPMUX_STATE_STOPPING)) { if (!nn_backoff_isidle (&ctcpmux->retry) || !nn_usock_isidle (&ctcpmux->usock) || !nn_dns_isidle (&ctcpmux->dns)) return; ctcpmux->state = NN_CTCPMUX_STATE_IDLE; nn_fsm_stopped_noevent (&ctcpmux->fsm); nn_epbase_stopped (&ctcpmux->epbase); return; } nn_fsm_bad_state (ctcpmux->state, src, type); } static void nn_ctcpmux_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_ctcpmux *ctcpmux; struct nn_iovec iovec; ctcpmux = nn_cont (self, struct nn_ctcpmux, fsm); switch (ctcpmux->state) { /******************************************************************************/ /* IDLE state. */ /* The state machine wasn't yet started. */ /******************************************************************************/ case NN_CTCPMUX_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_ctcpmux_start_resolving (ctcpmux); return; default: nn_fsm_bad_action (ctcpmux->state, src, type); } default: nn_fsm_bad_source (ctcpmux->state, src, type); } /******************************************************************************/ /* RESOLVING state. */ /* Name of the host to connect to is being resolved to get an IP address. */ /******************************************************************************/ case NN_CTCPMUX_STATE_RESOLVING: switch (src) { case NN_CTCPMUX_SRC_DNS: switch (type) { case NN_DNS_DONE: nn_dns_stop (&ctcpmux->dns); ctcpmux->state = NN_CTCPMUX_STATE_STOPPING_DNS; return; default: nn_fsm_bad_action (ctcpmux->state, src, type); } default: nn_fsm_bad_source (ctcpmux->state, src, type); } /******************************************************************************/ /* STOPPING_DNS state. */ /* dns object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_CTCPMUX_STATE_STOPPING_DNS: switch (src) { case NN_CTCPMUX_SRC_DNS: switch (type) { case NN_DNS_STOPPED: if (ctcpmux->dns_result.error == 0) { nn_ctcpmux_start_connecting (ctcpmux, &ctcpmux->dns_result.addr, ctcpmux->dns_result.addrlen); return; } nn_backoff_start (&ctcpmux->retry); ctcpmux->state = NN_CTCPMUX_STATE_WAITING; return; default: nn_fsm_bad_action (ctcpmux->state, src, type); } default: nn_fsm_bad_source (ctcpmux->state, src, type); } /******************************************************************************/ /* CONNECTING state. */ /* Non-blocking connect is under way. */ /******************************************************************************/ case NN_CTCPMUX_STATE_CONNECTING: switch (src) { case NN_CTCPMUX_SRC_USOCK: switch (type) { case NN_USOCK_CONNECTED: nn_epbase_stat_increment (&ctcpmux->epbase, NN_STAT_INPROGRESS_CONNECTIONS, -1); nn_epbase_stat_increment (&ctcpmux->epbase, NN_STAT_ESTABLISHED_CONNECTIONS, 1); nn_epbase_clear_error (&ctcpmux->epbase); iovec.iov_base = ctcpmux->buffer; iovec.iov_len = strlen (ctcpmux->buffer); nn_usock_send (&ctcpmux->usock, &iovec, 1); ctcpmux->state = NN_CTCPMUX_STATE_SENDING_TCPMUXHDR; return; case NN_USOCK_ERROR: nn_epbase_set_error (&ctcpmux->epbase, nn_usock_geterrno (&ctcpmux->usock)); nn_usock_stop (&ctcpmux->usock); ctcpmux->state = NN_CTCPMUX_STATE_STOPPING_USOCK; nn_epbase_stat_increment (&ctcpmux->epbase, NN_STAT_INPROGRESS_CONNECTIONS, -1); nn_epbase_stat_increment (&ctcpmux->epbase, NN_STAT_CONNECT_ERRORS, 1); return; default: nn_fsm_bad_action (ctcpmux->state, src, type); } default: nn_fsm_bad_source (ctcpmux->state, src, type); } /******************************************************************************/ /* SENDING_TCPMUXHDR state. */ /******************************************************************************/ case NN_CTCPMUX_STATE_SENDING_TCPMUXHDR: switch (src) { case NN_CTCPMUX_SRC_USOCK: switch (type) { case NN_USOCK_SENT: nn_usock_recv (&ctcpmux->usock, ctcpmux->buffer, 3, NULL); ctcpmux->state = NN_CTCPMUX_STATE_RECEIVING_TCPMUXHDR; return; case NN_USOCK_ERROR: nn_epbase_set_error (&ctcpmux->epbase, nn_usock_geterrno (&ctcpmux->usock)); nn_usock_stop (&ctcpmux->usock); ctcpmux->state = NN_CTCPMUX_STATE_STOPPING_USOCK; return; default: nn_fsm_bad_action (ctcpmux->state, src, type); } default: nn_fsm_bad_source (ctcpmux->state, src, type); } /******************************************************************************/ /* RECEIVING_TCPMUXHDR state. */ /******************************************************************************/ case NN_CTCPMUX_STATE_RECEIVING_TCPMUXHDR: switch (src) { case NN_CTCPMUX_SRC_USOCK: switch (type) { case NN_USOCK_RECEIVED: if (ctcpmux->buffer [0] == '+' && ctcpmux->buffer [1] == 0x0d && ctcpmux->buffer [2] == 0x0a) { nn_stcpmux_start (&ctcpmux->stcpmux, &ctcpmux->usock); ctcpmux->state = NN_CTCPMUX_STATE_ACTIVE; return; } case NN_USOCK_ERROR: nn_epbase_set_error (&ctcpmux->epbase, nn_usock_geterrno (&ctcpmux->usock)); nn_usock_stop (&ctcpmux->usock); ctcpmux->state = NN_CTCPMUX_STATE_STOPPING_USOCK; return; default: nn_fsm_bad_action (ctcpmux->state, src, type); } default: nn_fsm_bad_source (ctcpmux->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /* Connection is established and handled by the stcpmux state machine. */ /******************************************************************************/ case NN_CTCPMUX_STATE_ACTIVE: switch (src) { case NN_CTCPMUX_SRC_STCPMUX: switch (type) { case NN_STCPMUX_ERROR: nn_stcpmux_stop (&ctcpmux->stcpmux); ctcpmux->state = NN_CTCPMUX_STATE_STOPPING_STCPMUX; nn_epbase_stat_increment (&ctcpmux->epbase, NN_STAT_BROKEN_CONNECTIONS, 1); return; default: nn_fsm_bad_action (ctcpmux->state, src, type); } default: nn_fsm_bad_source (ctcpmux->state, src, type); } /******************************************************************************/ /* STOPPING_STCPMUX state. */ /* stcpmux object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_CTCPMUX_STATE_STOPPING_STCPMUX: switch (src) { case NN_CTCPMUX_SRC_STCPMUX: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_STCPMUX_STOPPED: nn_usock_stop (&ctcpmux->usock); ctcpmux->state = NN_CTCPMUX_STATE_STOPPING_USOCK; return; default: nn_fsm_bad_action (ctcpmux->state, src, type); } default: nn_fsm_bad_source (ctcpmux->state, src, type); } /******************************************************************************/ /* STOPPING_USOCK state. */ /* usock object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_CTCPMUX_STATE_STOPPING_USOCK: switch (src) { case NN_CTCPMUX_SRC_USOCK: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_USOCK_STOPPED: nn_backoff_start (&ctcpmux->retry); ctcpmux->state = NN_CTCPMUX_STATE_WAITING; return; default: nn_fsm_bad_action (ctcpmux->state, src, type); } default: nn_fsm_bad_source (ctcpmux->state, src, type); } /******************************************************************************/ /* WAITING state. */ /* Waiting before re-connection is attempted. This way we won't overload */ /* the system by continuous re-connection attemps. */ /******************************************************************************/ case NN_CTCPMUX_STATE_WAITING: switch (src) { case NN_CTCPMUX_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_TIMEOUT: nn_backoff_stop (&ctcpmux->retry); ctcpmux->state = NN_CTCPMUX_STATE_STOPPING_BACKOFF; return; default: nn_fsm_bad_action (ctcpmux->state, src, type); } default: nn_fsm_bad_source (ctcpmux->state, src, type); } /******************************************************************************/ /* STOPPING_BACKOFF state. */ /* backoff object was asked to stop, but it haven't stopped yet. */ /******************************************************************************/ case NN_CTCPMUX_STATE_STOPPING_BACKOFF: switch (src) { case NN_CTCPMUX_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_STOPPED: nn_ctcpmux_start_resolving (ctcpmux); return; default: nn_fsm_bad_action (ctcpmux->state, src, type); } default: nn_fsm_bad_source (ctcpmux->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (ctcpmux->state, src, type); } } /******************************************************************************/ /* State machine actions. */ /******************************************************************************/ static void nn_ctcpmux_start_resolving (struct nn_ctcpmux *self) { const char *addr; const char *begin; const char *end; int ipv4only; size_t ipv4onlylen; /* Extract the hostname part from address string. */ addr = nn_epbase_getaddr (&self->epbase); begin = strchr (addr, ';'); if (!begin) begin = addr; else ++begin; end = strrchr (addr, ':'); nn_assert (end); /* Check whether IPv6 is to be used. */ ipv4onlylen = sizeof (ipv4only); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY, &ipv4only, &ipv4onlylen); nn_assert (ipv4onlylen == sizeof (ipv4only)); /* TODO: Get the actual value of IPV4ONLY option. */ nn_dns_start (&self->dns, begin, end - begin, ipv4only, &self->dns_result); self->state = NN_CTCPMUX_STATE_RESOLVING; } static void nn_ctcpmux_start_connecting (struct nn_ctcpmux *self, struct sockaddr_storage *ss, size_t sslen) { int rc; struct sockaddr_storage remote; size_t remotelen; struct sockaddr_storage local; size_t locallen; const char *addr; const char *end; const char *colon; const char *slash; const char *semicolon; uint16_t port; int ipv4only; size_t ipv4onlylen; int val; size_t sz; /* Create IP address from the address string. */ addr = nn_epbase_getaddr (&self->epbase); memset (&remote, 0, sizeof (remote)); semicolon = strchr (addr, ';'); colon = strchr ((semicolon ? semicolon : addr) + 1, ':'); slash = strchr (colon + 1, '/'); end = addr + strlen (addr); /* Parse the port. */ rc = nn_port_resolve (colon + 1, slash - colon - 1); errnum_assert (rc > 0, -rc); port = rc; /* Copy the URL to the buffer. Append it by CRLF. */ sz = end - (slash + 1); memcpy (self->buffer, slash + 1, sz); self->buffer [sz] = 0x0d; self->buffer [sz + 1] = 0x0a; self->buffer [sz + 2] = 0; /* Check whether IPv6 is to be used. */ ipv4onlylen = sizeof (ipv4only); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY, &ipv4only, &ipv4onlylen); nn_assert (ipv4onlylen == sizeof (ipv4only)); /* Parse the local address, if any. */ memset (&local, 0, sizeof (local)); if (semicolon) rc = nn_iface_resolve (addr, semicolon - addr, ipv4only, &local, &locallen); else rc = nn_iface_resolve ("*", 1, ipv4only, &local, &locallen); if (nn_slow (rc < 0)) { nn_backoff_start (&self->retry); self->state = NN_CTCPMUX_STATE_WAITING; return; } /* Combine the remote address and the port. */ remote = *ss; remotelen = sslen; if (remote.ss_family == AF_INET) ((struct sockaddr_in*) &remote)->sin_port = htons (port); else if (remote.ss_family == AF_INET6) ((struct sockaddr_in6*) &remote)->sin6_port = htons (port); else nn_assert (0); /* Try to start the underlying socket. */ rc = nn_usock_start (&self->usock, remote.ss_family, SOCK_STREAM, 0); if (nn_slow (rc < 0)) { nn_backoff_start (&self->retry); self->state = NN_CTCPMUX_STATE_WAITING; return; } /* Set the relevant socket options. */ sz = sizeof (val); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_SNDBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&self->usock, SOL_SOCKET, SO_SNDBUF, &val, sizeof (val)); sz = sizeof (val); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RCVBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&self->usock, SOL_SOCKET, SO_RCVBUF, &val, sizeof (val)); /* Bind the socket to the local network interface. */ rc = nn_usock_bind (&self->usock, (struct sockaddr*) &local, locallen); if (nn_slow (rc != 0)) { nn_backoff_start (&self->retry); self->state = NN_CTCPMUX_STATE_WAITING; return; } /* Start connecting. */ nn_usock_connect (&self->usock, (struct sockaddr*) &remote, remotelen); self->state = NN_CTCPMUX_STATE_CONNECTING; nn_epbase_stat_increment (&self->epbase, NN_STAT_INPROGRESS_CONNECTIONS, 1); } nanomsg-0.8-beta/src/transports/tcpmux/stcpmux.h0000664000175000017500000000547312623652600023055 0ustar00travistravis00000000000000/* Copyright (c) 2013-2014 Martin Sustrik 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. */ #ifndef NN_STCPMUX_INCLUDED #define NN_STCPMUX_INCLUDED #include "../../transport.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../utils/streamhdr.h" #include "../../utils/msg.h" /* This state machine handles TCPMUX connection from the point where it is established to the point when it is broken. */ #define NN_STCPMUX_ERROR 1 #define NN_STCPMUX_STOPPED 2 struct nn_stcpmux { /* The state machine. */ struct nn_fsm fsm; int state; /* The underlying socket. */ struct nn_usock *usock; /* Child state machine to do protocol header exchange. */ struct nn_streamhdr streamhdr; /* The original owner of the underlying socket. */ struct nn_fsm_owner usock_owner; /* Pipe connecting this TCPMUX connection to the nanomsg core. */ struct nn_pipebase pipebase; /* State of inbound state machine. */ int instate; /* Buffer used to store the header of incoming message. */ uint8_t inhdr [8]; /* Message being received at the moment. */ struct nn_msg inmsg; /* State of the outbound state machine. */ int outstate; /* Buffer used to store the header of outgoing message. */ uint8_t outhdr [8]; /* Message being sent at the moment. */ struct nn_msg outmsg; /* Event raised when the state machine ends. */ struct nn_fsm_event done; }; void nn_stcpmux_init (struct nn_stcpmux *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner); void nn_stcpmux_term (struct nn_stcpmux *self); int nn_stcpmux_isidle (struct nn_stcpmux *self); void nn_stcpmux_start (struct nn_stcpmux *self, struct nn_usock *usock); void nn_stcpmux_stop (struct nn_stcpmux *self); #endif nanomsg-0.8-beta/src/transports/tcpmux/stcpmux.c0000664000175000017500000003541112623652600023043 0ustar00travistravis00000000000000/* Copyright (c) 2013-2014 Martin Sustrik 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 "stcpmux.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/wire.h" #include "../../utils/int.h" #include "../../utils/attr.h" /* States of the object as a whole. */ #define NN_STCPMUX_STATE_IDLE 1 #define NN_STCPMUX_STATE_PROTOHDR 2 #define NN_STCPMUX_STATE_STOPPING_STREAMHDR 3 #define NN_STCPMUX_STATE_ACTIVE 4 #define NN_STCPMUX_STATE_SHUTTING_DOWN 5 #define NN_STCPMUX_STATE_DONE 6 #define NN_STCPMUX_STATE_STOPPING 7 /* Possible states of the inbound part of the object. */ #define NN_STCPMUX_INSTATE_HDR 1 #define NN_STCPMUX_INSTATE_BODY 2 #define NN_STCPMUX_INSTATE_HASMSG 3 /* Possible states of the outbound part of the object. */ #define NN_STCPMUX_OUTSTATE_IDLE 1 #define NN_STCPMUX_OUTSTATE_SENDING 2 /* Subordinate srcptr objects. */ #define NN_STCPMUX_SRC_USOCK 1 #define NN_STCPMUX_SRC_STREAMHDR 2 /* Stream is a special type of pipe. Implementation of the virtual pipe API. */ static int nn_stcpmux_send (struct nn_pipebase *self, struct nn_msg *msg); static int nn_stcpmux_recv (struct nn_pipebase *self, struct nn_msg *msg); const struct nn_pipebase_vfptr nn_stcpmux_pipebase_vfptr = { nn_stcpmux_send, nn_stcpmux_recv }; /* Private functions. */ static void nn_stcpmux_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_stcpmux_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); void nn_stcpmux_init (struct nn_stcpmux *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_stcpmux_handler, nn_stcpmux_shutdown, src, self, owner); self->state = NN_STCPMUX_STATE_IDLE; nn_streamhdr_init (&self->streamhdr, NN_STCPMUX_SRC_STREAMHDR, &self->fsm); self->usock = NULL; self->usock_owner.src = -1; self->usock_owner.fsm = NULL; nn_pipebase_init (&self->pipebase, &nn_stcpmux_pipebase_vfptr, epbase); self->instate = -1; nn_msg_init (&self->inmsg, 0); self->outstate = -1; nn_msg_init (&self->outmsg, 0); nn_fsm_event_init (&self->done); } void nn_stcpmux_term (struct nn_stcpmux *self) { nn_assert_state (self, NN_STCPMUX_STATE_IDLE); nn_fsm_event_term (&self->done); nn_msg_term (&self->outmsg); nn_msg_term (&self->inmsg); nn_pipebase_term (&self->pipebase); nn_streamhdr_term (&self->streamhdr); nn_fsm_term (&self->fsm); } int nn_stcpmux_isidle (struct nn_stcpmux *self) { return nn_fsm_isidle (&self->fsm); } void nn_stcpmux_start (struct nn_stcpmux *self, struct nn_usock *usock) { /* Take ownership of the underlying socket. */ nn_assert (self->usock == NULL && self->usock_owner.fsm == NULL); self->usock_owner.src = NN_STCPMUX_SRC_USOCK; self->usock_owner.fsm = &self->fsm; nn_usock_swap_owner (usock, &self->usock_owner); self->usock = usock; /* Launch the state machine. */ nn_fsm_start (&self->fsm); } void nn_stcpmux_stop (struct nn_stcpmux *self) { nn_fsm_stop (&self->fsm); } static int nn_stcpmux_send (struct nn_pipebase *self, struct nn_msg *msg) { struct nn_stcpmux *stcpmux; struct nn_iovec iov [3]; stcpmux = nn_cont (self, struct nn_stcpmux, pipebase); nn_assert_state (stcpmux, NN_STCPMUX_STATE_ACTIVE); nn_assert (stcpmux->outstate == NN_STCPMUX_OUTSTATE_IDLE); /* Move the message to the local storage. */ nn_msg_term (&stcpmux->outmsg); nn_msg_mv (&stcpmux->outmsg, msg); /* Serialise the message header. */ nn_putll (stcpmux->outhdr, nn_chunkref_size (&stcpmux->outmsg.sphdr) + nn_chunkref_size (&stcpmux->outmsg.body)); /* Start async sending. */ iov [0].iov_base = stcpmux->outhdr; iov [0].iov_len = sizeof (stcpmux->outhdr); iov [1].iov_base = nn_chunkref_data (&stcpmux->outmsg.sphdr); iov [1].iov_len = nn_chunkref_size (&stcpmux->outmsg.sphdr); iov [2].iov_base = nn_chunkref_data (&stcpmux->outmsg.body); iov [2].iov_len = nn_chunkref_size (&stcpmux->outmsg.body); nn_usock_send (stcpmux->usock, iov, 3); stcpmux->outstate = NN_STCPMUX_OUTSTATE_SENDING; return 0; } static int nn_stcpmux_recv (struct nn_pipebase *self, struct nn_msg *msg) { struct nn_stcpmux *stcpmux; stcpmux = nn_cont (self, struct nn_stcpmux, pipebase); nn_assert_state (stcpmux, NN_STCPMUX_STATE_ACTIVE); nn_assert (stcpmux->instate == NN_STCPMUX_INSTATE_HASMSG); /* Move received message to the user. */ nn_msg_mv (msg, &stcpmux->inmsg); nn_msg_init (&stcpmux->inmsg, 0); /* Start receiving new message. */ stcpmux->instate = NN_STCPMUX_INSTATE_HDR; nn_usock_recv (stcpmux->usock, stcpmux->inhdr, sizeof (stcpmux->inhdr), NULL); return 0; } static void nn_stcpmux_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_stcpmux *stcpmux; stcpmux = nn_cont (self, struct nn_stcpmux, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { nn_pipebase_stop (&stcpmux->pipebase); nn_streamhdr_stop (&stcpmux->streamhdr); stcpmux->state = NN_STCPMUX_STATE_STOPPING; } if (nn_slow (stcpmux->state == NN_STCPMUX_STATE_STOPPING)) { if (nn_streamhdr_isidle (&stcpmux->streamhdr)) { nn_usock_swap_owner (stcpmux->usock, &stcpmux->usock_owner); stcpmux->usock = NULL; stcpmux->usock_owner.src = -1; stcpmux->usock_owner.fsm = NULL; stcpmux->state = NN_STCPMUX_STATE_IDLE; nn_fsm_stopped (&stcpmux->fsm, NN_STCPMUX_STOPPED); return; } return; } nn_fsm_bad_state(stcpmux->state, src, type); } static void nn_stcpmux_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { int rc; struct nn_stcpmux *stcpmux; uint64_t size; stcpmux = nn_cont (self, struct nn_stcpmux, fsm); switch (stcpmux->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_STCPMUX_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_streamhdr_start (&stcpmux->streamhdr, stcpmux->usock, &stcpmux->pipebase); stcpmux->state = NN_STCPMUX_STATE_PROTOHDR; return; default: nn_fsm_bad_action (stcpmux->state, src, type); } default: nn_fsm_bad_source (stcpmux->state, src, type); } /******************************************************************************/ /* PROTOHDR state. */ /******************************************************************************/ case NN_STCPMUX_STATE_PROTOHDR: switch (src) { case NN_STCPMUX_SRC_STREAMHDR: switch (type) { case NN_STREAMHDR_OK: /* Before moving to the active state stop the streamhdr state machine. */ nn_streamhdr_stop (&stcpmux->streamhdr); stcpmux->state = NN_STCPMUX_STATE_STOPPING_STREAMHDR; return; case NN_STREAMHDR_ERROR: /* Raise the error and move directly to the DONE state. streamhdr object will be stopped later on. */ stcpmux->state = NN_STCPMUX_STATE_DONE; nn_fsm_raise (&stcpmux->fsm, &stcpmux->done, NN_STCPMUX_ERROR); return; default: nn_fsm_bad_action (stcpmux->state, src, type); } default: nn_fsm_bad_source (stcpmux->state, src, type); } /******************************************************************************/ /* STOPPING_STREAMHDR state. */ /******************************************************************************/ case NN_STCPMUX_STATE_STOPPING_STREAMHDR: switch (src) { case NN_STCPMUX_SRC_STREAMHDR: switch (type) { case NN_STREAMHDR_STOPPED: /* Start the pipe. */ rc = nn_pipebase_start (&stcpmux->pipebase); if (nn_slow (rc < 0)) { stcpmux->state = NN_STCPMUX_STATE_DONE; nn_fsm_raise (&stcpmux->fsm, &stcpmux->done, NN_STCPMUX_ERROR); return; } /* Start receiving a message in asynchronous manner. */ stcpmux->instate = NN_STCPMUX_INSTATE_HDR; nn_usock_recv (stcpmux->usock, &stcpmux->inhdr, sizeof (stcpmux->inhdr), NULL); /* Mark the pipe as available for sending. */ stcpmux->outstate = NN_STCPMUX_OUTSTATE_IDLE; stcpmux->state = NN_STCPMUX_STATE_ACTIVE; return; default: nn_fsm_bad_action (stcpmux->state, src, type); } default: nn_fsm_bad_source (stcpmux->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /******************************************************************************/ case NN_STCPMUX_STATE_ACTIVE: switch (src) { case NN_STCPMUX_SRC_USOCK: switch (type) { case NN_USOCK_SENT: /* The message is now fully sent. */ nn_assert (stcpmux->outstate == NN_STCPMUX_OUTSTATE_SENDING); stcpmux->outstate = NN_STCPMUX_OUTSTATE_IDLE; nn_msg_term (&stcpmux->outmsg); nn_msg_init (&stcpmux->outmsg, 0); nn_pipebase_sent (&stcpmux->pipebase); return; case NN_USOCK_RECEIVED: switch (stcpmux->instate) { case NN_STCPMUX_INSTATE_HDR: /* Message header was received. Allocate memory for the message. */ size = nn_getll (stcpmux->inhdr); nn_msg_term (&stcpmux->inmsg); nn_msg_init (&stcpmux->inmsg, (size_t) size); /* Special case when size of the message body is 0. */ if (!size) { stcpmux->instate = NN_STCPMUX_INSTATE_HASMSG; nn_pipebase_received (&stcpmux->pipebase); return; } /* Start receiving the message body. */ stcpmux->instate = NN_STCPMUX_INSTATE_BODY; nn_usock_recv (stcpmux->usock, nn_chunkref_data (&stcpmux->inmsg.body), (size_t) size, NULL); return; case NN_STCPMUX_INSTATE_BODY: /* Message body was received. Notify the owner that it can receive it. */ stcpmux->instate = NN_STCPMUX_INSTATE_HASMSG; nn_pipebase_received (&stcpmux->pipebase); return; default: nn_fsm_error("Unexpected socket instate", stcpmux->state, src, type); } case NN_USOCK_SHUTDOWN: nn_pipebase_stop (&stcpmux->pipebase); stcpmux->state = NN_STCPMUX_STATE_SHUTTING_DOWN; return; case NN_USOCK_ERROR: nn_pipebase_stop (&stcpmux->pipebase); stcpmux->state = NN_STCPMUX_STATE_DONE; nn_fsm_raise (&stcpmux->fsm, &stcpmux->done, NN_STCPMUX_ERROR); return; default: nn_fsm_bad_action (stcpmux->state, src, type); } default: nn_fsm_bad_source (stcpmux->state, src, type); } /******************************************************************************/ /* SHUTTING_DOWN state. */ /* The underlying connection is closed. We are just waiting that underlying */ /* usock being closed */ /******************************************************************************/ case NN_STCPMUX_STATE_SHUTTING_DOWN: switch (src) { case NN_STCPMUX_SRC_USOCK: switch (type) { case NN_USOCK_ERROR: stcpmux->state = NN_STCPMUX_STATE_DONE; nn_fsm_raise (&stcpmux->fsm, &stcpmux->done, NN_STCPMUX_ERROR); return; default: nn_fsm_bad_action (stcpmux->state, src, type); } default: nn_fsm_bad_source (stcpmux->state, src, type); } /******************************************************************************/ /* DONE state. */ /* The underlying connection is closed. There's nothing that can be done in */ /* this state except stopping the object. */ /******************************************************************************/ case NN_STCPMUX_STATE_DONE: nn_fsm_bad_source (stcpmux->state, src, type); /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (stcpmux->state, src, type); } } nanomsg-0.8-beta/src/transports/tcpmux/tcpmux.h0000664000175000017500000000241012623652600022656 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik 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. */ #ifndef NN_TCPMUX_INCLUDED #define NN_TCPMUX_INCLUDED #include "../../transport.h" extern struct nn_transport *nn_tcpmux; #endif nanomsg-0.8-beta/src/transports/tcpmux/tcpmux.c0000664000175000017500000001100112623652600022645 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "tcpmux.h" #include "btcpmux.h" #include "ctcpmux.h" #include "../../tcpmux.h" #include "../utils/port.h" #include "../utils/iface.h" #include "../../utils/err.h" #include "../../utils/alloc.h" #include "../../utils/fast.h" #include "../../utils/list.h" #include "../../utils/cont.h" #include #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #endif /* TCPMUX-specific socket options. */ struct nn_tcpmux_optset { struct nn_optset base; int nodelay; }; static void nn_tcpmux_optset_destroy (struct nn_optset *self); static int nn_tcpmux_optset_setopt (struct nn_optset *self, int option, const void *optval, size_t optvallen); static int nn_tcpmux_optset_getopt (struct nn_optset *self, int option, void *optval, size_t *optvallen); static const struct nn_optset_vfptr nn_tcpmux_optset_vfptr = { nn_tcpmux_optset_destroy, nn_tcpmux_optset_setopt, nn_tcpmux_optset_getopt }; /* nn_transport interface. */ static int nn_tcpmux_bind (void *hint, struct nn_epbase **epbase); static int nn_tcpmux_connect (void *hint, struct nn_epbase **epbase); static struct nn_optset *nn_tcpmux_optset (void); static struct nn_transport nn_tcpmux_vfptr = { "tcpmux", NN_TCPMUX, NULL, NULL, nn_tcpmux_bind, nn_tcpmux_connect, nn_tcpmux_optset, NN_LIST_ITEM_INITIALIZER }; struct nn_transport *nn_tcpmux = &nn_tcpmux_vfptr; static int nn_tcpmux_bind (void *hint, struct nn_epbase **epbase) { #if defined NN_HAVE_WINDOWS return -EPROTONOSUPPORT; #else return nn_btcpmux_create (hint, epbase); #endif } static int nn_tcpmux_connect (void *hint, struct nn_epbase **epbase) { return nn_ctcpmux_create (hint, epbase); } static struct nn_optset *nn_tcpmux_optset () { struct nn_tcpmux_optset *optset; optset = nn_alloc (sizeof (struct nn_tcpmux_optset), "optset (tcpmux)"); alloc_assert (optset); optset->base.vfptr = &nn_tcpmux_optset_vfptr; /* Default values for TCPMUX socket options. */ optset->nodelay = 0; return &optset->base; } static void nn_tcpmux_optset_destroy (struct nn_optset *self) { struct nn_tcpmux_optset *optset; optset = nn_cont (self, struct nn_tcpmux_optset, base); nn_free (optset); } static int nn_tcpmux_optset_setopt (struct nn_optset *self, int option, const void *optval, size_t optvallen) { struct nn_tcpmux_optset *optset; int val; optset = nn_cont (self, struct nn_tcpmux_optset, base); /* At this point we assume that all options are of type int. */ if (optvallen != sizeof (int)) return -EINVAL; val = *(int*) optval; switch (option) { case NN_TCPMUX_NODELAY: if (nn_slow (val != 0 && val != 1)) return -EINVAL; optset->nodelay = val; return 0; default: return -ENOPROTOOPT; } } static int nn_tcpmux_optset_getopt (struct nn_optset *self, int option, void *optval, size_t *optvallen) { struct nn_tcpmux_optset *optset; int intval; optset = nn_cont (self, struct nn_tcpmux_optset, base); switch (option) { case NN_TCPMUX_NODELAY: intval = optset->nodelay; break; default: return -ENOPROTOOPT; } memcpy (optval, &intval, *optvallen < sizeof (int) ? *optvallen : sizeof (int)); *optvallen = sizeof (int); return 0; } nanomsg-0.8-beta/src/transports/utils/0000775000175000017500000000000012623652617021020 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/transports/utils/backoff.h0000664000175000017500000000362012623652600022555 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_BACKOFF_INCLUDED #define NN_BACKOFF_INCLUDED #include "../../aio/timer.h" /* Timer with exponential backoff. Actual wating time is (2^n-1)*minivl, meaning that first wait is 0 ms long, second one is minivl ms long etc. */ #define NN_BACKOFF_TIMEOUT NN_TIMER_TIMEOUT #define NN_BACKOFF_STOPPED NN_TIMER_STOPPED struct nn_backoff { struct nn_timer timer; int minivl; int maxivl; int n; }; void nn_backoff_init (struct nn_backoff *self, int src, int minivl, int maxivl, struct nn_fsm *owner); void nn_backoff_term (struct nn_backoff *self); int nn_backoff_isidle (struct nn_backoff *self); void nn_backoff_start (struct nn_backoff *self); void nn_backoff_stop (struct nn_backoff *self); void nn_backoff_reset (struct nn_backoff *self); #endif nanomsg-0.8-beta/src/transports/utils/backoff.c0000664000175000017500000000413612623652600022553 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "backoff.h" void nn_backoff_init (struct nn_backoff *self, int src, int minivl, int maxivl, struct nn_fsm *owner) { nn_timer_init (&self->timer, src, owner); self->minivl = minivl; self->maxivl = maxivl; self->n = 1; } void nn_backoff_term (struct nn_backoff *self) { nn_timer_term (&self->timer); } int nn_backoff_isidle (struct nn_backoff *self) { return nn_timer_isidle (&self->timer); } void nn_backoff_start (struct nn_backoff *self) { int timeout; /* Start the timer for the actual n value. If the interval haven't yet exceeded the maximum, double the next timeout value. */ timeout = (self->n - 1) * self->minivl; if (timeout > self->maxivl) timeout = self->maxivl; else self->n *= 2; nn_timer_start (&self->timer, timeout); } void nn_backoff_stop (struct nn_backoff *self) { nn_timer_stop (&self->timer); } void nn_backoff_reset (struct nn_backoff *self) { self->n = 1; } nanomsg-0.8-beta/src/transports/utils/dns.h0000664000175000017500000000404112623652600021744 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_DNS_INCLUDED #define NN_DNS_INCLUDED #include "../../aio/fsm.h" #include /* Checks the hostname according to RFC 952 and RFC 1123. Returns 0 in case the it is valid. */ int nn_dns_check_hostname (const char *name, size_t namelen); /* Events generated by the DNS state machine. */ #define NN_DNS_DONE 1 #define NN_DNS_STOPPED 2 #if defined NN_HAVE_GETADDRINFO_A && !defined NN_DISABLE_GETADDRINFO_A #include "dns_getaddrinfo_a.h" #else #include "dns_getaddrinfo.h" #endif struct nn_dns_result { int error; struct sockaddr_storage addr; size_t addrlen; }; void nn_dns_init (struct nn_dns *self, int src, struct nn_fsm *owner); void nn_dns_term (struct nn_dns *self); int nn_dns_isidle (struct nn_dns *self); void nn_dns_start (struct nn_dns *self, const char *addr, size_t addrlen, int ipv4only, struct nn_dns_result *result); void nn_dns_stop (struct nn_dns *self); #endif nanomsg-0.8-beta/src/transports/utils/dns.c0000664000175000017500000000544012623652600021743 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "dns.h" #include "../../utils/err.h" #include int nn_dns_check_hostname (const char *name, size_t namelen) { int labelsz; /* There has to be at least one label in the hostname. Additionally, hostnames are up to 255 characters long. */ if (namelen < 1 || namelen > 255) return -EINVAL; /* Hyphen can't be used as a first character of the hostname. */ if (*name == '-') return -EINVAL; labelsz = 0; while (1) { /* End of the hostname. */ if (namelen == 0) { /* The last label cannot be empty. */ if (labelsz == 0) return -EINVAL; /* Success! */ return 0; } /* End of a label. */ if (*name == '.') { /* The old label cannot be empty. */ if (labelsz == 0) return -EINVAL; /* Start new label. */ labelsz = 0; ++name; --namelen; continue; } /* Valid character. */ if ((*name >= 'a' && *name <= 'z') || (*name >= 'A' && *name <= 'Z') || (*name >= '0' && *name <= '9') || *name == '-') { ++name; --namelen; ++labelsz; /* Labels longer than 63 charcters are not permitted. */ if (labelsz > 63) return -EINVAL; continue; } /* Invalid character. */ return -EINVAL; } } #if defined NN_HAVE_GETADDRINFO_A && !defined NN_DISABLE_GETADDRINFO_A #include "dns_getaddrinfo_a.inc" #else #include "dns_getaddrinfo.inc" #endif nanomsg-0.8-beta/src/transports/utils/dns_getaddrinfo.h0000664000175000017500000000253512623652600024320 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #endif struct nn_dns { struct nn_fsm fsm; int state; struct nn_dns_result *result; struct nn_fsm_event done; }; nanomsg-0.8-beta/src/transports/utils/dns_getaddrinfo.inc0000664000175000017500000001334312623652600024641 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "literal.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/attr.h" #include #ifndef NN_HAVE_WINDOWS #include #include #include #endif #define NN_DNS_STATE_IDLE 1 #define NN_DNS_STATE_DONE 2 /* Private functions. */ static void nn_dns_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_dns_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); void nn_dns_init (struct nn_dns *self, int src, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_dns_handler, nn_dns_shutdown, src, self, owner); self->state = NN_DNS_STATE_IDLE; nn_fsm_event_init (&self->done); } void nn_dns_term (struct nn_dns *self) { nn_assert_state (self, NN_DNS_STATE_IDLE); nn_fsm_event_term (&self->done); nn_fsm_term (&self->fsm); } int nn_dns_isidle (struct nn_dns *self) { return nn_fsm_isidle (&self->fsm); } void nn_dns_start (struct nn_dns *self, const char *addr, size_t addrlen, int ipv4only, struct nn_dns_result *result) { int rc; struct addrinfo query; struct addrinfo *reply; char hostname [NN_SOCKADDR_MAX]; nn_assert_state (self, NN_DNS_STATE_IDLE); self->result = result; /* Try to resolve the supplied string as a literal address. In this case, there's no DNS lookup involved. */ rc = nn_literal_resolve (addr, addrlen, ipv4only, &self->result->addr, &self->result->addrlen); if (rc == 0) { self->result->error = 0; nn_fsm_start (&self->fsm); return; } errnum_assert (rc == -EINVAL, -rc); /* The name is not a literal. Let's do an actual DNS lookup. */ memset (&query, 0, sizeof (query)); if (ipv4only) query.ai_family = AF_INET; else { query.ai_family = AF_INET6; #ifdef AI_V4MAPPED query.ai_flags = AI_V4MAPPED; #endif } nn_assert (sizeof (hostname) > addrlen); query.ai_socktype = SOCK_STREAM; memcpy (hostname, addr, addrlen); hostname [addrlen] = 0; /* Perform the DNS lookup itself. */ self->result->error = getaddrinfo (hostname, NULL, &query, &reply); if (self->result->error) { nn_fsm_start (&self->fsm); return; } /* Take just the first address and store it. (RFC recommends that we iterate through addresses until one works, but that doesn't match our state model. This is the best we can do.) */ self->result->error = 0; memcpy (&self->result->addr, reply->ai_addr, reply->ai_addrlen); self->result->addrlen = reply->ai_addrlen; freeaddrinfo (reply); nn_fsm_start (&self->fsm); } void nn_dns_stop (struct nn_dns *self) { nn_fsm_stop (&self->fsm); } static void nn_dns_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_dns *dns; dns = nn_cont (self, struct nn_dns, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { nn_fsm_stopped (&dns->fsm, NN_DNS_STOPPED); dns->state = NN_DNS_STATE_IDLE; return; } nn_fsm_bad_state(dns->state, src, type); } static void nn_dns_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_dns *dns; dns = nn_cont (self, struct nn_dns, fsm); switch (dns->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_DNS_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_fsm_raise (&dns->fsm, &dns->done, NN_DNS_DONE); dns->state = NN_DNS_STATE_DONE; return; default: nn_fsm_bad_action (dns->state, src, type); } default: nn_fsm_bad_source (dns->state, src, type); } /******************************************************************************/ /* DONE state. */ /******************************************************************************/ case NN_DNS_STATE_DONE: nn_fsm_bad_source (dns->state, src, type); /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (dns->state, src, type); } } nanomsg-0.8-beta/src/transports/utils/dns_getaddrinfo_a.h0000664000175000017500000000275712623652600024626 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 #include "../../nn.h" #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #endif struct nn_dns { struct nn_fsm fsm; int state; int error; char hostname [NN_SOCKADDR_MAX]; struct addrinfo request; struct gaicb gcb; struct nn_dns_result *result; struct nn_fsm_event done; }; nanomsg-0.8-beta/src/transports/utils/dns_getaddrinfo_a.inc0000664000175000017500000002045512623652600025143 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "literal.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/attr.h" #include "../../aio/ctx.h" #include #define NN_DNS_STATE_IDLE 1 #define NN_DNS_STATE_RESOLVING 2 #define NN_DNS_STATE_DONE 3 #define NN_DNS_STATE_STOPPING 4 #define NN_DNS_ACTION_DONE 1 #define NN_DNS_ACTION_CANCELLED 2 /* Private functions. */ static void nn_dns_notify (union sigval); static void nn_dns_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_dns_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); void nn_dns_init (struct nn_dns *self, int src, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_dns_handler, nn_dns_shutdown, src, self, owner); self->state = NN_DNS_STATE_IDLE; nn_fsm_event_init (&self->done); } void nn_dns_term (struct nn_dns *self) { nn_assert_state (self, NN_DNS_STATE_IDLE); nn_fsm_event_term (&self->done); nn_fsm_term (&self->fsm); } int nn_dns_isidle (struct nn_dns *self) { return nn_fsm_isidle (&self->fsm); } void nn_dns_start (struct nn_dns *self, const char *addr, size_t addrlen, int ipv4only, struct nn_dns_result *result) { int rc; struct gaicb *pgcb; struct sigevent sev; nn_assert_state (self, NN_DNS_STATE_IDLE); self->result = result; /* Try to resolve the supplied string as a literal address. In this case, there's no DNS lookup involved. */ rc = nn_literal_resolve (addr, addrlen, ipv4only, &self->result->addr, &self->result->addrlen); if (rc == 0) { self->result->error = 0; nn_fsm_start (&self->fsm); return; } errnum_assert (rc == -EINVAL, -rc); /* Make a zero-terminated copy of the address string. */ nn_assert (sizeof (self->hostname) > addrlen); memcpy (self->hostname, addr, addrlen); self->hostname [addrlen] = 0; /* Start asynchronous DNS lookup. */ memset (&self->request, 0, sizeof (self->request)); if (ipv4only) self->request.ai_family = AF_INET; else { self->request.ai_family = AF_INET6; #ifdef AI_V4MAPPED self->request.ai_flags = AI_V4MAPPED; #endif } self->request.ai_socktype = SOCK_STREAM; memset (&self->gcb, 0, sizeof (self->gcb)); self->gcb.ar_name = self->hostname; self->gcb.ar_service = NULL; self->gcb.ar_request = &self->request; self->gcb.ar_result = NULL; pgcb = &self->gcb; memset (&sev, 0, sizeof (sev)); sev.sigev_notify = SIGEV_THREAD; sev.sigev_notify_function = nn_dns_notify; sev.sigev_value.sival_ptr = self; rc = getaddrinfo_a (GAI_NOWAIT, &pgcb, 1, &sev); nn_assert (rc == 0); self->result->error = EINPROGRESS; nn_fsm_start (&self->fsm); } void nn_dns_stop (struct nn_dns *self) { nn_fsm_stop (&self->fsm); } static void nn_dns_notify (union sigval sval) { int rc; struct nn_dns *self; self = (struct nn_dns*) sval.sival_ptr; nn_ctx_enter (self->fsm.ctx); rc = gai_error (&self->gcb); if (rc == EAI_CANCELED) { nn_fsm_action (&self->fsm, NN_DNS_ACTION_CANCELLED); } else if (rc != 0) { self->result->error = EINVAL; nn_fsm_action (&self->fsm, NN_DNS_ACTION_DONE); } else { self->result->error = 0; nn_assert (self->gcb.ar_result->ai_addrlen <= sizeof (struct sockaddr_storage)); memcpy (&self->result->addr, self->gcb.ar_result->ai_addr, self->gcb.ar_result->ai_addrlen); self->result->addrlen = (size_t) self->gcb.ar_result->ai_addrlen; freeaddrinfo(self->gcb.ar_result); nn_fsm_action (&self->fsm, NN_DNS_ACTION_DONE); } nn_ctx_leave (self->fsm.ctx); } static void nn_dns_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { int rc; struct nn_dns *dns; dns = nn_cont (self, struct nn_dns, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { if (dns->state == NN_DNS_STATE_RESOLVING) { rc = gai_cancel (&dns->gcb); if (rc == EAI_CANCELED) { nn_fsm_stopped (&dns->fsm, NN_DNS_STOPPED); dns->state = NN_DNS_STATE_IDLE; return; } if (rc == EAI_NOTCANCELED || rc == EAI_ALLDONE) { dns->state = NN_DNS_STATE_STOPPING; return; } nn_assert (0); } nn_fsm_stopped (&dns->fsm, NN_DNS_STOPPED); dns->state = NN_DNS_STATE_IDLE; return; } if (nn_slow (dns->state == NN_DNS_STATE_STOPPING)) { if (src == NN_FSM_ACTION && (type == NN_DNS_ACTION_CANCELLED || type == NN_DNS_ACTION_DONE)) { nn_fsm_stopped (&dns->fsm, NN_DNS_STOPPED); dns->state = NN_DNS_STATE_IDLE; return; } return; } nn_fsm_bad_state (dns->state, src, type); } static void nn_dns_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_dns *dns; dns = nn_cont (self, struct nn_dns, fsm); switch (dns->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_DNS_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: if (dns->result->error == EINPROGRESS) { dns->state = NN_DNS_STATE_RESOLVING; return; } nn_fsm_raise (&dns->fsm, &dns->done, NN_DNS_DONE); dns->state = NN_DNS_STATE_DONE; return; default: nn_fsm_bad_action (dns->state, src, type); } default: nn_fsm_bad_source (dns->state, src, type); } /******************************************************************************/ /* RESOLVING state. */ /******************************************************************************/ case NN_DNS_STATE_RESOLVING: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_DNS_ACTION_DONE: nn_fsm_raise (&dns->fsm, &dns->done, NN_DNS_DONE); dns->state = NN_DNS_STATE_DONE; return; default: nn_fsm_bad_action (dns->state, src, type); } default: nn_fsm_bad_source (dns->state, src, type); } /******************************************************************************/ /* DONE state. */ /******************************************************************************/ case NN_DNS_STATE_DONE: nn_fsm_bad_source (dns->state, src, type); /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (dns->state, src, type); } } nanomsg-0.8-beta/src/transports/utils/iface.h0000664000175000017500000000305512623652600022233 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_IFACE_INCLUDED #define NN_IFACE_INCLUDED #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #endif #include /* Resolves name of a local network interface into the address itself. Name '*' is resolved as 'all interfaces'. */ int nn_iface_resolve (const char *addr, size_t addrlen, int ipv4only, struct sockaddr_storage *result, size_t *resultlen); #endif nanomsg-0.8-beta/src/transports/utils/iface.c0000664000175000017500000000547612623652600022237 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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 "iface.h" #include "literal.h" #include "../../utils/err.h" #include "../../utils/closefd.h" #include #ifndef NN_HAVE_WINDOWS #include #include #endif /* Private functions. */ static void nn_iface_any (int ipv4only, struct sockaddr_storage *result, size_t *resultlen); /* We no longer resolve interface names. This feature was non-portable and fragile. Only IP addresses may be used. They are provided in the form of string literals. */ int nn_iface_resolve (const char *addr, size_t addrlen, int ipv4only, struct sockaddr_storage *result, size_t *resultlen) { int rc; /* Asterisk is a special name meaning "all interfaces". */ if (addrlen == 1 && addr [0] == '*') { nn_iface_any (ipv4only, result, resultlen); return 0; } rc = nn_literal_resolve (addr, addrlen, ipv4only, result, resultlen); if (rc == -EINVAL) return -ENODEV; errnum_assert (rc == 0, -rc); return 0; } static void nn_iface_any (int ipv4only, struct sockaddr_storage *result, size_t *resultlen) { if (ipv4only) { if (result) { result->ss_family = AF_INET; ((struct sockaddr_in*) result)->sin_addr.s_addr = htonl (INADDR_ANY); } if (resultlen) *resultlen = sizeof (struct sockaddr_in); } else { if (result) { result->ss_family = AF_INET6; memcpy (&((struct sockaddr_in6*) result)->sin6_addr, &in6addr_any, sizeof (in6addr_any)); } if (resultlen) *resultlen = sizeof (struct sockaddr_in6); } } nanomsg-0.8-beta/src/transports/utils/literal.h0000664000175000017500000000275212623652600022623 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_LITERAL_INCLUDED #define NN_LITERAL_INCLUDED #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #endif #include /* Resolves a literal IPv4 or IPv6 address. */ int nn_literal_resolve (const char *addr, size_t addrlen, int ipv4only, struct sockaddr_storage *result, size_t *resultlen); #endif nanomsg-0.8-beta/src/transports/utils/literal.c0000664000175000017500000001016312623652600022611 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "literal.h" #include "../../utils/err.h" #include "../../utils/fast.h" #include #ifndef NN_HAVE_WINDOWS #include #include #endif /* On Windows XS there's no inet_pton() function. */ #if defined NN_HAVE_WINDOWS && ((_WIN32_WINNT <= 0x0501) || (WINVER <= 0x0501)) static int nn_inet_pton(int family, const char *src, void *dst) { int rc; struct sockaddr_storage addr; int addr_len = sizeof(addr); if (nn_slow (family != AF_INET && family != AF_INET6)) { errno = EAFNOSUPPORT; return -1; } addr.ss_family = family; rc = WSAStringToAddressA ((char*) src, family, NULL, (struct sockaddr*) &addr, &addr_len); if (rc != 0) return 0; if (family == AF_INET) { memcpy(dst, &((struct sockaddr_in *) &addr)->sin_addr, sizeof(struct in_addr)); } else if (family == AF_INET6) { memcpy(dst, &((struct sockaddr_in6 *)&addr)->sin6_addr, sizeof(struct in6_addr)); } return 1; } #else static int nn_inet_pton(int family, const char *src, void *dst) { return inet_pton (family, src, dst); } #endif int nn_literal_resolve (const char *addr, size_t addrlen, int ipv4only, struct sockaddr_storage *result, size_t *resultlen) { int rc; char addrz [INET6_ADDRSTRLEN > INET_ADDRSTRLEN ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN]; struct in_addr inaddr; struct in6_addr in6addr; /* Try to treat the address as a literal string. If the size of the address is larger than longest possible literal, skip the step. If the literal in enclosed in square brackets ignore them. */ if (addrlen > 0 && addr [0] == '[') { if (addr [addrlen - 1] != ']') return -EINVAL; if (addrlen - 2 + 1 > sizeof (addrz)) return -EINVAL; memcpy (addrz, addr + 1, addrlen - 2); addrz [addrlen - 2] = 0; } else { if (addrlen + 1 > sizeof (addrz)) return -EINVAL; memcpy (addrz, addr, addrlen); addrz [addrlen] = 0; } /* Try to interpret the literal as an IPv6 address. */ if (!ipv4only) { rc = nn_inet_pton (AF_INET6, addrz, &in6addr); if (rc == 1) { if (result) { result->ss_family = AF_INET6; ((struct sockaddr_in6*) result)->sin6_addr = in6addr; } if (resultlen) *resultlen = sizeof (struct sockaddr_in6); return 0; } errno_assert (rc == 0); } /* Try to interpret the literal as an IPv4 address. */ rc = nn_inet_pton (AF_INET, addrz, &inaddr); if (rc == 1) { if (result) { result->ss_family = AF_INET; ((struct sockaddr_in*) result)->sin_addr = inaddr; } if (resultlen) *resultlen = sizeof (struct sockaddr_in); return 0; } errno_assert (rc == 0); /* The supplied string is not a valid literal address. */ return -EINVAL; } nanomsg-0.8-beta/src/transports/utils/port.h0000664000175000017500000000263612623652600022154 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_PORT_INCLUDED #define NN_PORT_INCLUDED #include /* Parse the string containing a port number. Returns port number in integer form or -EINVAL if the string doesn't contain a port number. */ int nn_port_resolve (const char *port, size_t portlen); #endif nanomsg-0.8-beta/src/transports/utils/port.c0000664000175000017500000000330212623652600022136 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "port.h" #include "../../utils/err.h" int nn_port_resolve (const char *port, size_t portlen) { int res; size_t i; res = 0; for (i = 0; i != portlen; ++i) { if (port [i] < '0' || port [i] > '9') return -EINVAL; res *= 10; res += port [i] - '0'; if (res > 0xffff) return -EINVAL; } /* Port 0 has special meaning (assign an ephemeral port to the socket), thus it is illegal to use it in the connection string. */ if (res == 0) return -EINVAL; return res; } nanomsg-0.8-beta/src/transports/utils/streamhdr.h0000664000175000017500000000463412623652600023161 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_STREAMHDR_INCLUDED #define NN_STREAMHDR_INCLUDED #include "../../transport.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../../aio/timer.h" #include "../../utils/int.h" /* This state machine exchanges protocol headers on top of a stream-based bi-directional connection. */ #define NN_STREAMHDR_OK 1 #define NN_STREAMHDR_ERROR 2 #define NN_STREAMHDR_STOPPED 3 struct nn_streamhdr { /* The state machine. */ struct nn_fsm fsm; int state; /* Used to timeout the protocol header exchange. */ struct nn_timer timer; /* The underlying socket. */ struct nn_usock *usock; /* The original owner of the underlying socket. */ struct nn_fsm_owner usock_owner; /* Handle to the pipe. */ struct nn_pipebase *pipebase; /* Protocol header. */ uint8_t protohdr [8]; /* Event fired when the state machine ends. */ struct nn_fsm_event done; }; void nn_streamhdr_init (struct nn_streamhdr *self, int src, struct nn_fsm *owner); void nn_streamhdr_term (struct nn_streamhdr *self); int nn_streamhdr_isidle (struct nn_streamhdr *self); void nn_streamhdr_start (struct nn_streamhdr *self, struct nn_usock *usock, struct nn_pipebase *pipebase); void nn_streamhdr_stop (struct nn_streamhdr *self); #endif nanomsg-0.8-beta/src/transports/utils/streamhdr.c0000664000175000017500000002701612623652600023153 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "streamhdr.h" #include "../../aio/timer.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/wire.h" #include "../../utils/attr.h" #include #include #define NN_STREAMHDR_STATE_IDLE 1 #define NN_STREAMHDR_STATE_SENDING 2 #define NN_STREAMHDR_STATE_RECEIVING 3 #define NN_STREAMHDR_STATE_STOPPING_TIMER_ERROR 4 #define NN_STREAMHDR_STATE_STOPPING_TIMER_DONE 5 #define NN_STREAMHDR_STATE_DONE 6 #define NN_STREAMHDR_STATE_STOPPING 7 #define NN_STREAMHDR_SRC_USOCK 1 #define NN_STREAMHDR_SRC_TIMER 2 /* Private functions. */ static void nn_streamhdr_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_streamhdr_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); void nn_streamhdr_init (struct nn_streamhdr *self, int src, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_streamhdr_handler, nn_streamhdr_shutdown, src, self, owner); self->state = NN_STREAMHDR_STATE_IDLE; nn_timer_init (&self->timer, NN_STREAMHDR_SRC_TIMER, &self->fsm); nn_fsm_event_init (&self->done); self->usock = NULL; self->usock_owner.src = -1; self->usock_owner.fsm = NULL; self->pipebase = NULL; } void nn_streamhdr_term (struct nn_streamhdr *self) { nn_assert_state (self, NN_STREAMHDR_STATE_IDLE); nn_fsm_event_term (&self->done); nn_timer_term (&self->timer); nn_fsm_term (&self->fsm); } int nn_streamhdr_isidle (struct nn_streamhdr *self) { return nn_fsm_isidle (&self->fsm); } void nn_streamhdr_start (struct nn_streamhdr *self, struct nn_usock *usock, struct nn_pipebase *pipebase) { size_t sz; int protocol; /* Take ownership of the underlying socket. */ nn_assert (self->usock == NULL && self->usock_owner.fsm == NULL); self->usock_owner.src = NN_STREAMHDR_SRC_USOCK; self->usock_owner.fsm = &self->fsm; nn_usock_swap_owner (usock, &self->usock_owner); self->usock = usock; self->pipebase = pipebase; /* Get the protocol identifier. */ sz = sizeof (protocol); nn_pipebase_getopt (pipebase, NN_SOL_SOCKET, NN_PROTOCOL, &protocol, &sz); nn_assert (sz == sizeof (protocol)); /* Compose the protocol header. */ memcpy (self->protohdr, "\0SP\0\0\0\0\0", 8); nn_puts (self->protohdr + 4, (uint16_t) protocol); /* Launch the state machine. */ nn_fsm_start (&self->fsm); } void nn_streamhdr_stop (struct nn_streamhdr *self) { nn_fsm_stop (&self->fsm); } static void nn_streamhdr_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_streamhdr *streamhdr; streamhdr = nn_cont (self, struct nn_streamhdr, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { nn_timer_stop (&streamhdr->timer); streamhdr->state = NN_STREAMHDR_STATE_STOPPING; } if (nn_slow (streamhdr->state == NN_STREAMHDR_STATE_STOPPING)) { if (!nn_timer_isidle (&streamhdr->timer)) return; streamhdr->state = NN_STREAMHDR_STATE_IDLE; nn_fsm_stopped (&streamhdr->fsm, NN_STREAMHDR_STOPPED); return; } nn_fsm_bad_state (streamhdr->state, src, type); } static void nn_streamhdr_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_streamhdr *streamhdr; struct nn_iovec iovec; int protocol; streamhdr = nn_cont (self, struct nn_streamhdr, fsm); switch (streamhdr->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_STREAMHDR_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_timer_start (&streamhdr->timer, 1000); iovec.iov_base = streamhdr->protohdr; iovec.iov_len = sizeof (streamhdr->protohdr); nn_usock_send (streamhdr->usock, &iovec, 1); streamhdr->state = NN_STREAMHDR_STATE_SENDING; return; default: nn_fsm_bad_action (streamhdr->state, src, type); } default: nn_fsm_bad_source (streamhdr->state, src, type); } /******************************************************************************/ /* SENDING state. */ /******************************************************************************/ case NN_STREAMHDR_STATE_SENDING: switch (src) { case NN_STREAMHDR_SRC_USOCK: switch (type) { case NN_USOCK_SENT: nn_usock_recv (streamhdr->usock, streamhdr->protohdr, sizeof (streamhdr->protohdr), NULL); streamhdr->state = NN_STREAMHDR_STATE_RECEIVING; return; case NN_USOCK_SHUTDOWN: /* Ignore it. Wait for ERROR event */ return; case NN_USOCK_ERROR: nn_timer_stop (&streamhdr->timer); streamhdr->state = NN_STREAMHDR_STATE_STOPPING_TIMER_ERROR; return; default: nn_fsm_bad_action (streamhdr->state, src, type); } case NN_STREAMHDR_SRC_TIMER: switch (type) { case NN_TIMER_TIMEOUT: nn_timer_stop (&streamhdr->timer); streamhdr->state = NN_STREAMHDR_STATE_STOPPING_TIMER_ERROR; return; default: nn_fsm_bad_action (streamhdr->state, src, type); } default: nn_fsm_bad_source (streamhdr->state, src, type); } /******************************************************************************/ /* RECEIVING state. */ /******************************************************************************/ case NN_STREAMHDR_STATE_RECEIVING: switch (src) { case NN_STREAMHDR_SRC_USOCK: switch (type) { case NN_USOCK_RECEIVED: /* Here we are checking whether the peer speaks the same protocol as this socket. */ if (memcmp (streamhdr->protohdr, "\0SP\0", 4) != 0) goto invalidhdr; protocol = nn_gets (streamhdr->protohdr + 4); if (!nn_pipebase_ispeer (streamhdr->pipebase, protocol)) goto invalidhdr; nn_timer_stop (&streamhdr->timer); streamhdr->state = NN_STREAMHDR_STATE_STOPPING_TIMER_DONE; return; case NN_USOCK_SHUTDOWN: /* Ignore it. Wait for ERROR event */ return; case NN_USOCK_ERROR: invalidhdr: nn_timer_stop (&streamhdr->timer); streamhdr->state = NN_STREAMHDR_STATE_STOPPING_TIMER_ERROR; return; default: nn_assert (0); } case NN_STREAMHDR_SRC_TIMER: switch (type) { case NN_TIMER_TIMEOUT: nn_timer_stop (&streamhdr->timer); streamhdr->state = NN_STREAMHDR_STATE_STOPPING_TIMER_ERROR; return; default: nn_fsm_bad_action (streamhdr->state, src, type); } default: nn_fsm_bad_source (streamhdr->state, src, type); } /******************************************************************************/ /* STOPPING_TIMER_ERROR state. */ /******************************************************************************/ case NN_STREAMHDR_STATE_STOPPING_TIMER_ERROR: switch (src) { case NN_STREAMHDR_SRC_USOCK: /* It's safe to ignore usock event when we are stopping */ return; case NN_STREAMHDR_SRC_TIMER: switch (type) { case NN_TIMER_STOPPED: nn_usock_swap_owner (streamhdr->usock, &streamhdr->usock_owner); streamhdr->usock = NULL; streamhdr->usock_owner.src = -1; streamhdr->usock_owner.fsm = NULL; streamhdr->state = NN_STREAMHDR_STATE_DONE; nn_fsm_raise (&streamhdr->fsm, &streamhdr->done, NN_STREAMHDR_ERROR); return; default: nn_fsm_bad_action (streamhdr->state, src, type); } default: nn_fsm_bad_source (streamhdr->state, src, type); } /******************************************************************************/ /* STOPPING_TIMER_DONE state. */ /******************************************************************************/ case NN_STREAMHDR_STATE_STOPPING_TIMER_DONE: switch (src) { case NN_STREAMHDR_SRC_TIMER: switch (type) { case NN_TIMER_STOPPED: nn_usock_swap_owner (streamhdr->usock, &streamhdr->usock_owner); streamhdr->usock = NULL; streamhdr->usock_owner.src = -1; streamhdr->usock_owner.fsm = NULL; streamhdr->state = NN_STREAMHDR_STATE_DONE; nn_fsm_raise (&streamhdr->fsm, &streamhdr->done, NN_STREAMHDR_OK); return; default: nn_fsm_bad_action (streamhdr->state, src, type); } default: nn_fsm_bad_source (streamhdr->state, src, type); } /******************************************************************************/ /* DONE state. */ /* The header exchange was either done successfully of failed. There's */ /* nothing that can be done in this state except stopping the object. */ /******************************************************************************/ case NN_STREAMHDR_STATE_DONE: nn_fsm_bad_source (streamhdr->state, src, type); /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (streamhdr->state, src, type); } } nanomsg-0.8-beta/src/transports/utils/base64.h0000664000175000017500000000331212623652600022244 0ustar00travistravis00000000000000/* Copyright (c) 2014 Wirebird Labs LLC. 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. */ #ifndef NN_BASE64_INCLUDED #define NN_BASE64_INCLUDED #include "../../utils/int.h" #include "../../utils/err.h" #include /* Based on base64.c (Public Domain) by Jon Mayo. Base64 is defined in RFC 2045, section 6.8. */ /* This function encodes an arbitrary byte array into base64 null-terminated string. */ int nn_base64_encode (const uint8_t *in, size_t in_len, char *out, size_t out_len); /* This function decodes a base64 string into supplied buffer. */ int nn_base64_decode (const char *in, size_t in_len, uint8_t *out, size_t out_len); #endif nanomsg-0.8-beta/src/transports/utils/base64.c0000664000175000017500000001163612623652600022247 0ustar00travistravis00000000000000/* Copyright (c) 2014 Wirebird Labs LLC. 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 "base64.h" #include int nn_base64_decode (const char *in, size_t in_len, uint8_t *out, size_t out_len) { unsigned ii; unsigned io; unsigned rem; uint32_t v; uint8_t ch; /* Unrolled lookup of ASCII code points. 0xFF represents a non-base64 valid character. */ const uint8_t DECODEMAP [256] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3E, 0xFF, 0xFF, 0xFF, 0x3F, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0xFF, 0xFF, 0xFF, 0x3E, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; for (io = 0, ii = 0, v = 0, rem = 0; ii < in_len; ii++) { if (isspace (in [ii])) continue; if (in [ii] == '=') break; ch = DECODEMAP [(int)(in [ii])]; /* Discard invalid characters as per RFC 2045. */ if (ch == 0xFF) break; v = (v << 6) | ch; rem += 6; if (rem >= 8) { rem -= 8; if (io >= out_len) return -ENOBUFS; out [io++] = (v >> rem) & 255; } } if (rem >= 8) { rem -= 8; if (io >= out_len) return -ENOBUFS; out [io++] = (v >> rem) & 255; } return io; } int nn_base64_encode (const uint8_t *in, size_t in_len, char *out, size_t out_len) { unsigned ii; unsigned io; unsigned rem; uint32_t v; uint8_t ch; const uint8_t ENCODEMAP [64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; for (io = 0, ii = 0, v = 0, rem = 0; ii < in_len; ii++) { ch = in [ii]; v = (v << 8) | ch; rem += 8; while (rem >= 6) { rem -= 6; if (io >= out_len) return -ENOBUFS; out [io++] = ENCODEMAP [(v >> rem) & 63]; } } if (rem) { v <<= (6 - rem); if (io >= out_len) return -ENOBUFS; out [io++] = ENCODEMAP [v & 63]; } /* Pad to a multiple of 3. */ while (io & 3) { if (io >= out_len) return -ENOBUFS; out [io++] = '='; } if (io >= out_len) return -ENOBUFS; out [io] = '\0'; return io; } nanomsg-0.8-beta/src/transports/ws/0000775000175000017500000000000012623652617020311 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/transports/ws/aws.h0000664000175000017500000000523412623652600021250 0ustar00travistravis00000000000000/* Copyright (c) 2013 250bpm s.r.o. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. 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. */ #ifndef NN_AWS_INCLUDED #define NN_AWS_INCLUDED #include "sws.h" #include "../../transport.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../../utils/list.h" /* State machine handling accepted WS sockets. */ /* In bws, some events are just *assumed* to come from a child aws object. By using non-trivial event codes, we can do more reliable sanity checking in such scenarios. */ #define NN_AWS_ACCEPTED 34231 #define NN_AWS_ERROR 34232 #define NN_AWS_STOPPED 34233 struct nn_aws { /* The state machine. */ struct nn_fsm fsm; int state; /* Pointer to the associated endpoint. */ struct nn_epbase *epbase; /* Underlying socket. */ struct nn_usock usock; /* Listening socket. Valid only while accepting new connection. */ struct nn_usock *listener; struct nn_fsm_owner listener_owner; /* State machine that takes care of the connection in the active state. */ struct nn_sws sws; /* Events generated by aws state machine. */ struct nn_fsm_event accepted; struct nn_fsm_event done; /* This member can be used by owner to keep individual awss in a list. */ struct nn_list_item item; }; void nn_aws_init (struct nn_aws *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner); void nn_aws_term (struct nn_aws *self); int nn_aws_isidle (struct nn_aws *self); void nn_aws_start (struct nn_aws *self, struct nn_usock *listener); void nn_aws_stop (struct nn_aws *self); #endif nanomsg-0.8-beta/src/transports/ws/aws.c0000664000175000017500000002705712623652600021252 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 250bpm s.r.o. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. All rights reserved. Copyright 2015 Garrett D'Amore 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 "aws.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/attr.h" #include "../../ws.h" #define NN_AWS_STATE_IDLE 1 #define NN_AWS_STATE_ACCEPTING 2 #define NN_AWS_STATE_ACTIVE 3 #define NN_AWS_STATE_STOPPING_SWS 4 #define NN_AWS_STATE_STOPPING_USOCK 5 #define NN_AWS_STATE_DONE 6 #define NN_AWS_STATE_STOPPING_SWS_FINAL 7 #define NN_AWS_STATE_STOPPING 8 #define NN_AWS_SRC_USOCK 1 #define NN_AWS_SRC_SWS 2 #define NN_AWS_SRC_LISTENER 3 /* Private functions. */ static void nn_aws_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_aws_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); void nn_aws_init (struct nn_aws *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_aws_handler, nn_aws_shutdown, src, self, owner); self->state = NN_AWS_STATE_IDLE; self->epbase = epbase; nn_usock_init (&self->usock, NN_AWS_SRC_USOCK, &self->fsm); self->listener = NULL; self->listener_owner.src = -1; self->listener_owner.fsm = NULL; nn_sws_init (&self->sws, NN_AWS_SRC_SWS, epbase, &self->fsm); nn_fsm_event_init (&self->accepted); nn_fsm_event_init (&self->done); nn_list_item_init (&self->item); } void nn_aws_term (struct nn_aws *self) { nn_assert_state (self, NN_AWS_STATE_IDLE); nn_list_item_term (&self->item); nn_fsm_event_term (&self->done); nn_fsm_event_term (&self->accepted); nn_sws_term (&self->sws); nn_usock_term (&self->usock); nn_fsm_term (&self->fsm); } int nn_aws_isidle (struct nn_aws *self) { return nn_fsm_isidle (&self->fsm); } void nn_aws_start (struct nn_aws *self, struct nn_usock *listener) { nn_assert_state (self, NN_AWS_STATE_IDLE); /* Take ownership of the listener socket. */ self->listener = listener; self->listener_owner.src = NN_AWS_SRC_LISTENER; self->listener_owner.fsm = &self->fsm; nn_usock_swap_owner (listener, &self->listener_owner); /* Start the state machine. */ nn_fsm_start (&self->fsm); } void nn_aws_stop (struct nn_aws *self) { nn_fsm_stop (&self->fsm); } static void nn_aws_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_aws *aws; aws = nn_cont (self, struct nn_aws, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { if (!nn_sws_isidle (&aws->sws)) { nn_epbase_stat_increment (aws->epbase, NN_STAT_DROPPED_CONNECTIONS, 1); nn_sws_stop (&aws->sws); } aws->state = NN_AWS_STATE_STOPPING_SWS_FINAL; } if (nn_slow (aws->state == NN_AWS_STATE_STOPPING_SWS_FINAL)) { if (!nn_sws_isidle (&aws->sws)) return; nn_usock_stop (&aws->usock); aws->state = NN_AWS_STATE_STOPPING; } if (nn_slow (aws->state == NN_AWS_STATE_STOPPING)) { if (!nn_usock_isidle (&aws->usock)) return; if (aws->listener) { nn_assert (aws->listener_owner.fsm); nn_usock_swap_owner (aws->listener, &aws->listener_owner); aws->listener = NULL; aws->listener_owner.src = -1; aws->listener_owner.fsm = NULL; } aws->state = NN_AWS_STATE_IDLE; nn_fsm_stopped (&aws->fsm, NN_AWS_STOPPED); return; } nn_fsm_bad_action (aws->state, src, type); } static void nn_aws_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_aws *aws; int val; size_t sz; uint8_t msg_type; aws = nn_cont (self, struct nn_aws, fsm); switch (aws->state) { /******************************************************************************/ /* IDLE state. */ /* The state machine wasn't yet started. */ /******************************************************************************/ case NN_AWS_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_usock_accept (&aws->usock, aws->listener); aws->state = NN_AWS_STATE_ACCEPTING; return; default: nn_fsm_bad_action (aws->state, src, type); } default: nn_fsm_bad_source (aws->state, src, type); } /******************************************************************************/ /* ACCEPTING state. */ /* Waiting for incoming connection. */ /******************************************************************************/ case NN_AWS_STATE_ACCEPTING: switch (src) { case NN_AWS_SRC_USOCK: switch (type) { case NN_USOCK_ACCEPTED: nn_epbase_clear_error (aws->epbase); /* Set the relevant socket options. */ sz = sizeof (val); nn_epbase_getopt (aws->epbase, NN_SOL_SOCKET, NN_SNDBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&aws->usock, SOL_SOCKET, SO_SNDBUF, &val, sizeof (val)); sz = sizeof (val); nn_epbase_getopt (aws->epbase, NN_SOL_SOCKET, NN_RCVBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&aws->usock, SOL_SOCKET, SO_RCVBUF, &val, sizeof (val)); sz = sizeof (val); nn_epbase_getopt (aws->epbase, NN_WS, NN_WS_MSG_TYPE, &val, &sz); msg_type = (uint8_t)val; /* Since the WebSocket handshake must poll, the receive timeout is set to zero. Later, it will be set again to the value specified by the socket option. */ val = 0; sz = sizeof (val); nn_usock_setsockopt (&aws->usock, SOL_SOCKET, SO_RCVTIMEO, &val, sizeof (val)); /* Return ownership of the listening socket to the parent. */ nn_usock_swap_owner (aws->listener, &aws->listener_owner); aws->listener = NULL; aws->listener_owner.src = -1; aws->listener_owner.fsm = NULL; nn_fsm_raise (&aws->fsm, &aws->accepted, NN_AWS_ACCEPTED); /* Start the sws state machine. */ nn_usock_activate (&aws->usock); nn_sws_start (&aws->sws, &aws->usock, NN_WS_SERVER, NULL, NULL, msg_type); aws->state = NN_AWS_STATE_ACTIVE; nn_epbase_stat_increment (aws->epbase, NN_STAT_ACCEPTED_CONNECTIONS, 1); return; default: nn_fsm_bad_action (aws->state, src, type); } case NN_AWS_SRC_LISTENER: switch (type) { case NN_USOCK_ACCEPT_ERROR: nn_epbase_set_error (aws->epbase, nn_usock_geterrno (aws->listener)); nn_epbase_stat_increment (aws->epbase, NN_STAT_ACCEPT_ERRORS, 1); nn_usock_accept (&aws->usock, aws->listener); return; default: nn_fsm_bad_action (aws->state, src, type); } default: nn_fsm_bad_source (aws->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /******************************************************************************/ case NN_AWS_STATE_ACTIVE: switch (src) { case NN_AWS_SRC_SWS: switch (type) { case NN_SWS_RETURN_CLOSE_HANDSHAKE: /* Peer closed connection without intention to reconnect, or local endpoint failed remote because of invalid data. */ nn_sws_stop (&aws->sws); aws->state = NN_AWS_STATE_STOPPING_SWS; return; case NN_SWS_RETURN_ERROR: nn_sws_stop (&aws->sws); aws->state = NN_AWS_STATE_STOPPING_SWS; nn_epbase_stat_increment (aws->epbase, NN_STAT_BROKEN_CONNECTIONS, 1); return; default: nn_fsm_bad_action (aws->state, src, type); } default: nn_fsm_bad_source (aws->state, src, type); } /******************************************************************************/ /* STOPPING_SWS state. */ /******************************************************************************/ case NN_AWS_STATE_STOPPING_SWS: switch (src) { case NN_AWS_SRC_SWS: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_SWS_RETURN_STOPPED: nn_usock_stop (&aws->usock); aws->state = NN_AWS_STATE_STOPPING_USOCK; return; default: nn_fsm_bad_action (aws->state, src, type); } default: nn_fsm_bad_source (aws->state, src, type); } /******************************************************************************/ /* STOPPING_USOCK state. */ /******************************************************************************/ case NN_AWS_STATE_STOPPING_USOCK: switch (src) { case NN_AWS_SRC_USOCK: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_USOCK_STOPPED: nn_aws_stop (aws); return; default: nn_fsm_bad_action (aws->state, src, type); } default: nn_fsm_bad_source (aws->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (aws->state, src, type); } } nanomsg-0.8-beta/src/transports/ws/bws.h0000664000175000017500000000260112623652600021244 0ustar00travistravis00000000000000/* Copyright (c) 2013 250bpm s.r.o. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. 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. */ #ifndef NN_BWS_INCLUDED #define NN_BWS_INCLUDED #include "../../transport.h" /* State machine managing bound WS socket. */ int nn_bws_create (void *hint, struct nn_epbase **epbase); #endif nanomsg-0.8-beta/src/transports/ws/bws.c0000664000175000017500000002774012623652600021252 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 250bpm s.r.o. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. 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 "bws.h" #include "aws.h" #include "../utils/port.h" #include "../utils/iface.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/alloc.h" #include "../../utils/list.h" #include "../../utils/fast.h" #include "../../utils/int.h" #include #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #include #endif /* The backlog is set relatively high so that there are not too many failed connection attemps during re-connection storms. */ #define NN_BWS_BACKLOG 100 #define NN_BWS_STATE_IDLE 1 #define NN_BWS_STATE_ACTIVE 2 #define NN_BWS_STATE_STOPPING_AWS 3 #define NN_BWS_STATE_STOPPING_USOCK 4 #define NN_BWS_STATE_STOPPING_AWSS 5 #define NN_BWS_SRC_USOCK 1 #define NN_BWS_SRC_AWS 2 struct nn_bws { /* The state machine. */ struct nn_fsm fsm; int state; /* This object is a specific type of endpoint. Thus it is derived from epbase. */ struct nn_epbase epbase; /* The underlying listening WS socket. */ struct nn_usock usock; /* The connection being accepted at the moment. */ struct nn_aws *aws; /* List of accepted connections. */ struct nn_list awss; }; /* nn_epbase virtual interface implementation. */ static void nn_bws_stop (struct nn_epbase *self); static void nn_bws_destroy (struct nn_epbase *self); const struct nn_epbase_vfptr nn_bws_epbase_vfptr = { nn_bws_stop, nn_bws_destroy }; /* Private functions. */ static void nn_bws_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_bws_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_bws_start_listening (struct nn_bws *self); static void nn_bws_start_accepting (struct nn_bws *self); int nn_bws_create (void *hint, struct nn_epbase **epbase) { int rc; struct nn_bws *self; const char *addr; const char *end; const char *pos; struct sockaddr_storage ss; size_t sslen; int ipv4only; size_t ipv4onlylen; /* Allocate the new endpoint object. */ self = nn_alloc (sizeof (struct nn_bws), "bws"); alloc_assert (self); /* Initalise the epbase. */ nn_epbase_init (&self->epbase, &nn_bws_epbase_vfptr, hint); addr = nn_epbase_getaddr (&self->epbase); /* Parse the port. */ end = addr + strlen (addr); pos = strrchr (addr, ':'); if (nn_slow (!pos)) { nn_epbase_term (&self->epbase); return -EINVAL; } ++pos; rc = nn_port_resolve (pos, end - pos); if (nn_slow (rc < 0)) { nn_epbase_term (&self->epbase); return -EINVAL; } /* Check whether IPv6 is to be used. */ ipv4onlylen = sizeof (ipv4only); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY, &ipv4only, &ipv4onlylen); nn_assert (ipv4onlylen == sizeof (ipv4only)); /* Parse the address. */ rc = nn_iface_resolve (addr, pos - addr - 1, ipv4only, &ss, &sslen); if (nn_slow (rc < 0)) { nn_epbase_term (&self->epbase); return -ENODEV; } /* Initialise the structure. */ nn_fsm_init_root (&self->fsm, nn_bws_handler, nn_bws_shutdown, nn_epbase_getctx (&self->epbase)); self->state = NN_BWS_STATE_IDLE; nn_usock_init (&self->usock, NN_BWS_SRC_USOCK, &self->fsm); self->aws = NULL; nn_list_init (&self->awss); /* Start the state machine. */ nn_fsm_start (&self->fsm); /* Return the base class as an out parameter. */ *epbase = &self->epbase; return 0; } static void nn_bws_stop (struct nn_epbase *self) { struct nn_bws *bws; bws = nn_cont (self, struct nn_bws, epbase); nn_fsm_stop (&bws->fsm); } static void nn_bws_destroy (struct nn_epbase *self) { struct nn_bws *bws; bws = nn_cont (self, struct nn_bws, epbase); nn_assert_state (bws, NN_BWS_STATE_IDLE); nn_list_term (&bws->awss); nn_assert (bws->aws == NULL); nn_usock_term (&bws->usock); nn_epbase_term (&bws->epbase); nn_fsm_term (&bws->fsm); nn_free (bws); } static void nn_bws_shutdown (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_bws *bws; struct nn_list_item *it; struct nn_aws *aws; bws = nn_cont (self, struct nn_bws, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { nn_aws_stop (bws->aws); bws->state = NN_BWS_STATE_STOPPING_AWS; } if (nn_slow (bws->state == NN_BWS_STATE_STOPPING_AWS)) { if (!nn_aws_isidle (bws->aws)) return; nn_aws_term (bws->aws); nn_free (bws->aws); bws->aws = NULL; nn_usock_stop (&bws->usock); bws->state = NN_BWS_STATE_STOPPING_USOCK; } if (nn_slow (bws->state == NN_BWS_STATE_STOPPING_USOCK)) { if (!nn_usock_isidle (&bws->usock)) return; for (it = nn_list_begin (&bws->awss); it != nn_list_end (&bws->awss); it = nn_list_next (&bws->awss, it)) { aws = nn_cont (it, struct nn_aws, item); nn_aws_stop (aws); } bws->state = NN_BWS_STATE_STOPPING_AWSS; goto awss_stopping; } if (nn_slow (bws->state == NN_BWS_STATE_STOPPING_AWSS)) { nn_assert (src == NN_BWS_SRC_AWS && type == NN_AWS_STOPPED); aws = (struct nn_aws *) srcptr; nn_list_erase (&bws->awss, &aws->item); nn_aws_term (aws); nn_free (aws); /* If there are no more aws state machines, we can stop the whole bws object. */ awss_stopping: if (nn_list_empty (&bws->awss)) { bws->state = NN_BWS_STATE_IDLE; nn_fsm_stopped_noevent (&bws->fsm); nn_epbase_stopped (&bws->epbase); return; } return; } nn_fsm_bad_action (bws->state, src, type); } static void nn_bws_handler (struct nn_fsm *self, int src, int type, void *srcptr) { struct nn_bws *bws; struct nn_aws *aws; bws = nn_cont (self, struct nn_bws, fsm); switch (bws->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_BWS_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_bws_start_listening (bws); nn_bws_start_accepting (bws); bws->state = NN_BWS_STATE_ACTIVE; return; default: nn_fsm_bad_action (bws->state, src, type); } default: nn_fsm_bad_source (bws->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /* The execution is yielded to the aws state machine in this state. */ /******************************************************************************/ case NN_BWS_STATE_ACTIVE: if (srcptr == bws->aws) { switch (type) { case NN_AWS_ACCEPTED: /* Move the newly created connection to the list of existing connections. */ nn_list_insert (&bws->awss, &bws->aws->item, nn_list_end (&bws->awss)); bws->aws = NULL; /* Start waiting for a new incoming connection. */ nn_bws_start_accepting (bws); return; default: nn_fsm_bad_action (bws->state, src, type); } } /* For all remaining events we'll assume they are coming from one of remaining child aws objects. */ nn_assert (src == NN_BWS_SRC_AWS); aws = (struct nn_aws*) srcptr; switch (type) { case NN_AWS_ERROR: nn_aws_stop (aws); return; case NN_AWS_STOPPED: nn_list_erase (&bws->awss, &aws->item); nn_aws_term (aws); nn_free (aws); return; default: nn_fsm_bad_action (bws->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (bws->state, src, type); } } /******************************************************************************/ /* State machine actions. */ /******************************************************************************/ static void nn_bws_start_listening (struct nn_bws *self) { int rc; struct sockaddr_storage ss; size_t sslen; int ipv4only; size_t ipv4onlylen; const char *addr; const char *end; const char *pos; uint16_t port; /* First, resolve the IP address. */ addr = nn_epbase_getaddr (&self->epbase); memset (&ss, 0, sizeof (ss)); /* Parse the port. */ end = addr + strlen (addr); pos = strrchr (addr, ':'); nn_assert (pos); ++pos; rc = nn_port_resolve (pos, end - pos); nn_assert (rc >= 0); port = rc; /* Parse the address. */ ipv4onlylen = sizeof (ipv4only); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY, &ipv4only, &ipv4onlylen); nn_assert (ipv4onlylen == sizeof (ipv4only)); rc = nn_iface_resolve (addr, pos - addr - 1, ipv4only, &ss, &sslen); errnum_assert (rc == 0, -rc); /* Combine the port and the address. */ if (ss.ss_family == AF_INET) { ((struct sockaddr_in*) &ss)->sin_port = htons (port); sslen = sizeof (struct sockaddr_in); } else if (ss.ss_family == AF_INET6) { ((struct sockaddr_in6*) &ss)->sin6_port = htons (port); sslen = sizeof (struct sockaddr_in6); } else nn_assert (0); /* Start listening for incoming connections. */ rc = nn_usock_start (&self->usock, ss.ss_family, SOCK_STREAM, 0); /* TODO: EMFILE error can happen here. We can wait a bit and re-try. */ errnum_assert (rc == 0, -rc); rc = nn_usock_bind (&self->usock, (struct sockaddr*) &ss, (size_t) sslen); errnum_assert (rc == 0, -rc); rc = nn_usock_listen (&self->usock, NN_BWS_BACKLOG); errnum_assert (rc == 0, -rc); } static void nn_bws_start_accepting (struct nn_bws *self) { nn_assert (self->aws == NULL); /* Allocate new aws state machine. */ self->aws = nn_alloc (sizeof (struct nn_aws), "aws"); alloc_assert (self->aws); nn_aws_init (self->aws, NN_BWS_SRC_AWS, &self->epbase, &self->fsm); /* Start waiting for a new incoming connection. */ nn_aws_start (self->aws, &self->usock); } nanomsg-0.8-beta/src/transports/ws/cws.h0000664000175000017500000000260512623652600021251 0ustar00travistravis00000000000000/* Copyright (c) 2013 250bpm s.r.o. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. 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. */ #ifndef NN_CWS_INCLUDED #define NN_CWS_INCLUDED #include "../../transport.h" /* State machine managing connected WS socket. */ int nn_cws_create (void *hint, struct nn_epbase **epbase); #endif nanomsg-0.8-beta/src/transports/ws/cws.c0000664000175000017500000005605712623652600021256 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 250bpm s.r.o. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. All rights reserved. Copyright 2015 Garrett D'Amore 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 "cws.h" #include "sws.h" #include "../../ws.h" #include "../utils/dns.h" #include "../utils/port.h" #include "../utils/iface.h" #include "../utils/backoff.h" #include "../utils/literal.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/alloc.h" #include "../../utils/fast.h" #include "../../utils/int.h" #include "../../utils/attr.h" #include #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #include #include #endif #define NN_CWS_STATE_IDLE 1 #define NN_CWS_STATE_RESOLVING 2 #define NN_CWS_STATE_STOPPING_DNS 3 #define NN_CWS_STATE_CONNECTING 4 #define NN_CWS_STATE_ACTIVE 5 #define NN_CWS_STATE_STOPPING_SWS 6 #define NN_CWS_STATE_STOPPING_USOCK 7 #define NN_CWS_STATE_WAITING 8 #define NN_CWS_STATE_STOPPING_BACKOFF 9 #define NN_CWS_STATE_STOPPING_SWS_FINAL 10 #define NN_CWS_STATE_STOPPING 11 #define NN_CWS_SRC_USOCK 1 #define NN_CWS_SRC_RECONNECT_TIMER 2 #define NN_CWS_SRC_DNS 3 #define NN_CWS_SRC_SWS 4 struct nn_cws { /* The state machine. */ struct nn_fsm fsm; int state; /* This object is a specific type of endpoint. Thus it is derived from epbase. */ struct nn_epbase epbase; /* The underlying WS socket. */ struct nn_usock usock; /* Used to wait before retrying to connect. */ struct nn_backoff retry; /* Defines message validation and framing. */ uint8_t msg_type; /* State machine that handles the active part of the connection lifetime. */ struct nn_sws sws; /* Parsed parts of the connection URI. */ struct nn_chunkref resource; struct nn_chunkref remote_host; struct nn_chunkref nic; int remote_port; int remote_hostname_len; /* If a close handshake is performed, this flag signals to not begin automatic reconnect retries. */ int peer_gone; /* DNS resolver used to convert textual address into actual IP address along with the variable to hold the result. */ struct nn_dns dns; struct nn_dns_result dns_result; }; /* nn_epbase virtual interface implementation. */ static void nn_cws_stop (struct nn_epbase *self); static void nn_cws_destroy (struct nn_epbase *self); const struct nn_epbase_vfptr nn_cws_epbase_vfptr = { nn_cws_stop, nn_cws_destroy }; /* Private functions. */ static void nn_cws_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_cws_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_cws_start_resolving (struct nn_cws *self); static void nn_cws_start_connecting (struct nn_cws *self, struct sockaddr_storage *ss, size_t sslen); int nn_cws_create (void *hint, struct nn_epbase **epbase) { int rc; const char *addr; size_t addrlen; const char *semicolon; const char *hostname; size_t hostlen; const char *colon; const char *slash; const char *resource; size_t resourcelen; struct sockaddr_storage ss; size_t sslen; int ipv4only; size_t ipv4onlylen; struct nn_cws *self; int reconnect_ivl; int reconnect_ivl_max; int msg_type; size_t sz; /* Allocate the new endpoint object. */ self = nn_alloc (sizeof (struct nn_cws), "cws"); alloc_assert (self); /* Initalise the endpoint. */ nn_epbase_init (&self->epbase, &nn_cws_epbase_vfptr, hint); /* Check whether IPv6 is to be used. */ ipv4onlylen = sizeof (ipv4only); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY, &ipv4only, &ipv4onlylen); nn_assert (ipv4onlylen == sizeof (ipv4only)); /* Start parsing the address. */ addr = nn_epbase_getaddr (&self->epbase); addrlen = strlen (addr); semicolon = strchr (addr, ';'); hostname = semicolon ? semicolon + 1 : addr; colon = strrchr (addr, ':'); slash = colon ? strchr (colon, '/') : strchr (addr, '/'); resource = slash ? slash : addr + addrlen; self->remote_hostname_len = colon ? colon - hostname : resource - hostname; /* Host contains both hostname and port. */ hostlen = resource - hostname; /* Parse the port; assume port 80 if not explicitly declared. */ if (nn_slow (colon != NULL)) { rc = nn_port_resolve (colon + 1, resource - colon - 1); if (nn_slow (rc < 0)) { nn_epbase_term (&self->epbase); return -EINVAL; } self->remote_port = rc; } else { self->remote_port = 80; } /* Check whether the host portion of the address is either a literal or a valid hostname. */ if (nn_dns_check_hostname (hostname, self->remote_hostname_len) < 0 && nn_literal_resolve (hostname, self->remote_hostname_len, ipv4only, &ss, &sslen) < 0) { nn_epbase_term (&self->epbase); return -EINVAL; } /* If local address is specified, check whether it is valid. */ if (semicolon) { rc = nn_iface_resolve (addr, semicolon - addr, ipv4only, &ss, &sslen); if (rc < 0) { nn_epbase_term (&self->epbase); return -ENODEV; } } /* At this point, the address is valid, so begin allocating resources. */ nn_chunkref_init (&self->remote_host, hostlen + 1); memcpy (nn_chunkref_data (&self->remote_host), hostname, hostlen); ((uint8_t *) nn_chunkref_data (&self->remote_host)) [hostlen] = '\0'; if (semicolon) { nn_chunkref_init (&self->nic, semicolon - addr); memcpy (nn_chunkref_data (&self->nic), addr, semicolon - addr); } else { nn_chunkref_init (&self->nic, 1); memcpy (nn_chunkref_data (&self->nic), "*", 1); } /* The requested resource is used in opening handshake. */ resourcelen = strlen (resource); if (resourcelen) { nn_chunkref_init (&self->resource, resourcelen + 1); strncpy (nn_chunkref_data (&self->resource), resource, resourcelen + 1); } else { /* No resource specified, so allocate base path. */ nn_chunkref_init (&self->resource, 2); strncpy (nn_chunkref_data (&self->resource), "/", 2); } /* Initialise the structure. */ nn_fsm_init_root (&self->fsm, nn_cws_handler, nn_cws_shutdown, nn_epbase_getctx (&self->epbase)); self->state = NN_CWS_STATE_IDLE; nn_usock_init (&self->usock, NN_CWS_SRC_USOCK, &self->fsm); sz = sizeof (msg_type); nn_epbase_getopt (&self->epbase, NN_WS, NN_WS_MSG_TYPE, &msg_type, &sz); nn_assert (sz == sizeof (msg_type)); self->msg_type = (uint8_t) msg_type; sz = sizeof (reconnect_ivl); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL, &reconnect_ivl, &sz); nn_assert (sz == sizeof (reconnect_ivl)); sz = sizeof (reconnect_ivl_max); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RECONNECT_IVL_MAX, &reconnect_ivl_max, &sz); nn_assert (sz == sizeof (reconnect_ivl_max)); if (reconnect_ivl_max == 0) reconnect_ivl_max = reconnect_ivl; nn_backoff_init (&self->retry, NN_CWS_SRC_RECONNECT_TIMER, reconnect_ivl, reconnect_ivl_max, &self->fsm); nn_sws_init (&self->sws, NN_CWS_SRC_SWS, &self->epbase, &self->fsm); nn_dns_init (&self->dns, NN_CWS_SRC_DNS, &self->fsm); /* Start the state machine. */ nn_fsm_start (&self->fsm); /* Return the base class as an out parameter. */ *epbase = &self->epbase; return 0; } static void nn_cws_stop (struct nn_epbase *self) { struct nn_cws *cws; cws = nn_cont (self, struct nn_cws, epbase); nn_fsm_stop (&cws->fsm); } static void nn_cws_destroy (struct nn_epbase *self) { struct nn_cws *cws; cws = nn_cont (self, struct nn_cws, epbase); nn_chunkref_term (&cws->resource); nn_chunkref_term (&cws->remote_host); nn_chunkref_term (&cws->nic); nn_dns_term (&cws->dns); nn_sws_term (&cws->sws); nn_backoff_term (&cws->retry); nn_usock_term (&cws->usock); nn_fsm_term (&cws->fsm); nn_epbase_term (&cws->epbase); nn_free (cws); } static void nn_cws_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_cws *cws; cws = nn_cont (self, struct nn_cws, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { if (!nn_sws_isidle (&cws->sws)) { nn_epbase_stat_increment (&cws->epbase, NN_STAT_DROPPED_CONNECTIONS, 1); nn_sws_stop (&cws->sws); } cws->state = NN_CWS_STATE_STOPPING_SWS_FINAL; } if (nn_slow (cws->state == NN_CWS_STATE_STOPPING_SWS_FINAL)) { if (!nn_sws_isidle (&cws->sws)) return; nn_backoff_stop (&cws->retry); nn_usock_stop (&cws->usock); nn_dns_stop (&cws->dns); cws->state = NN_CWS_STATE_STOPPING; } if (nn_slow (cws->state == NN_CWS_STATE_STOPPING)) { if (!nn_backoff_isidle (&cws->retry) || !nn_usock_isidle (&cws->usock) || !nn_dns_isidle (&cws->dns)) return; cws->state = NN_CWS_STATE_IDLE; nn_fsm_stopped_noevent (&cws->fsm); nn_epbase_stopped (&cws->epbase); return; } nn_fsm_bad_state (cws->state, src, type); } static void nn_cws_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_cws *cws; cws = nn_cont (self, struct nn_cws, fsm); switch (cws->state) { /******************************************************************************/ /* IDLE state. */ /* The state machine wasn't yet started. */ /******************************************************************************/ case NN_CWS_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_cws_start_resolving (cws); return; default: nn_fsm_bad_action (cws->state, src, type); } default: nn_fsm_bad_source (cws->state, src, type); } /******************************************************************************/ /* RESOLVING state. */ /* Name of the host to connect to is being resolved to get an IP address. */ /******************************************************************************/ case NN_CWS_STATE_RESOLVING: switch (src) { case NN_CWS_SRC_DNS: switch (type) { case NN_DNS_DONE: nn_dns_stop (&cws->dns); cws->state = NN_CWS_STATE_STOPPING_DNS; return; default: nn_fsm_bad_action (cws->state, src, type); } default: nn_fsm_bad_source (cws->state, src, type); } /******************************************************************************/ /* STOPPING_DNS state. */ /* dns object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_CWS_STATE_STOPPING_DNS: switch (src) { case NN_CWS_SRC_DNS: switch (type) { case NN_DNS_STOPPED: if (cws->dns_result.error == 0) { nn_cws_start_connecting (cws, &cws->dns_result.addr, cws->dns_result.addrlen); return; } nn_backoff_start (&cws->retry); cws->state = NN_CWS_STATE_WAITING; return; default: nn_fsm_bad_action (cws->state, src, type); } default: nn_fsm_bad_source (cws->state, src, type); } /******************************************************************************/ /* CONNECTING state. */ /* Non-blocking connect is under way. */ /******************************************************************************/ case NN_CWS_STATE_CONNECTING: switch (src) { case NN_CWS_SRC_USOCK: switch (type) { case NN_USOCK_CONNECTED: nn_sws_start (&cws->sws, &cws->usock, NN_WS_CLIENT, nn_chunkref_data (&cws->resource), nn_chunkref_data (&cws->remote_host), cws->msg_type); cws->state = NN_CWS_STATE_ACTIVE; cws->peer_gone = 0; nn_epbase_stat_increment (&cws->epbase, NN_STAT_INPROGRESS_CONNECTIONS, -1); nn_epbase_stat_increment (&cws->epbase, NN_STAT_ESTABLISHED_CONNECTIONS, 1); nn_epbase_clear_error (&cws->epbase); return; case NN_USOCK_ERROR: nn_epbase_set_error (&cws->epbase, nn_usock_geterrno (&cws->usock)); nn_usock_stop (&cws->usock); cws->state = NN_CWS_STATE_STOPPING_USOCK; nn_epbase_stat_increment (&cws->epbase, NN_STAT_INPROGRESS_CONNECTIONS, -1); nn_epbase_stat_increment (&cws->epbase, NN_STAT_CONNECT_ERRORS, 1); return; default: nn_fsm_bad_action (cws->state, src, type); } default: nn_fsm_bad_source (cws->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /* Connection is established and handled by the sws state machine. */ /******************************************************************************/ case NN_CWS_STATE_ACTIVE: switch (src) { case NN_CWS_SRC_SWS: switch (type) { case NN_SWS_RETURN_CLOSE_HANDSHAKE: /* Peer closed connection without intention to reconnect, or local endpoint failed remote because of invalid data. */ nn_sws_stop (&cws->sws); cws->state = NN_CWS_STATE_STOPPING_SWS; cws->peer_gone = 1; return; case NN_SWS_RETURN_ERROR: nn_sws_stop (&cws->sws); cws->state = NN_CWS_STATE_STOPPING_SWS; nn_epbase_stat_increment (&cws->epbase, NN_STAT_BROKEN_CONNECTIONS, 1); return; default: nn_fsm_bad_action (cws->state, src, type); } default: nn_fsm_bad_source (cws->state, src, type); } /******************************************************************************/ /* STOPPING_SWS state. */ /* sws object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_CWS_STATE_STOPPING_SWS: switch (src) { case NN_CWS_SRC_SWS: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_SWS_RETURN_STOPPED: nn_usock_stop (&cws->usock); cws->state = NN_CWS_STATE_STOPPING_USOCK; return; default: nn_fsm_bad_action (cws->state, src, type); } default: nn_fsm_bad_source (cws->state, src, type); } /******************************************************************************/ /* STOPPING_USOCK state. */ /* usock object was asked to stop but it haven't stopped yet. */ /******************************************************************************/ case NN_CWS_STATE_STOPPING_USOCK: switch (src) { case NN_CWS_SRC_USOCK: switch (type) { case NN_USOCK_SHUTDOWN: return; case NN_USOCK_STOPPED: /* If the peer has confirmed itself gone with a Closing Handshake, or if the local endpoint failed the remote, don't try to reconnect. */ if (cws->peer_gone) { /* It is expected that the application detects this and prunes the connection with nn_shutdown. */ } else { nn_backoff_start (&cws->retry); cws->state = NN_CWS_STATE_WAITING; } return; default: nn_fsm_bad_action (cws->state, src, type); } default: nn_fsm_bad_source (cws->state, src, type); } /******************************************************************************/ /* WAITING state. */ /* Waiting before re-connection is attempted. This way we won't overload */ /* the system by continuous re-connection attemps. */ /******************************************************************************/ case NN_CWS_STATE_WAITING: switch (src) { case NN_CWS_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_TIMEOUT: nn_backoff_stop (&cws->retry); cws->state = NN_CWS_STATE_STOPPING_BACKOFF; return; default: nn_fsm_bad_action (cws->state, src, type); } default: nn_fsm_bad_source (cws->state, src, type); } /******************************************************************************/ /* STOPPING_BACKOFF state. */ /* backoff object was asked to stop, but it haven't stopped yet. */ /******************************************************************************/ case NN_CWS_STATE_STOPPING_BACKOFF: switch (src) { case NN_CWS_SRC_RECONNECT_TIMER: switch (type) { case NN_BACKOFF_STOPPED: nn_cws_start_resolving (cws); return; default: nn_fsm_bad_action (cws->state, src, type); } default: nn_fsm_bad_source (cws->state, src, type); } /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (cws->state, src, type); } } /******************************************************************************/ /* State machine actions. */ /******************************************************************************/ static void nn_cws_start_resolving (struct nn_cws *self) { int ipv4only; size_t ipv4onlylen; char *host; /* Check whether IPv6 is to be used. */ ipv4onlylen = sizeof (ipv4only); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY, &ipv4only, &ipv4onlylen); nn_assert (ipv4onlylen == sizeof (ipv4only)); host = nn_chunkref_data (&self->remote_host); nn_assert (strlen (host) > 0); nn_dns_start (&self->dns, host, self->remote_hostname_len, ipv4only, &self->dns_result); self->state = NN_CWS_STATE_RESOLVING; } static void nn_cws_start_connecting (struct nn_cws *self, struct sockaddr_storage *ss, size_t sslen) { int rc; struct sockaddr_storage remote; size_t remotelen; struct sockaddr_storage local; size_t locallen; int ipv4only; size_t ipv4onlylen; int val; size_t sz; memset (&remote, 0, sizeof (remote)); memset (&local, 0, sizeof (local)); /* Check whether IPv6 is to be used. */ ipv4onlylen = sizeof (ipv4only); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY, &ipv4only, &ipv4onlylen); nn_assert (ipv4onlylen == sizeof (ipv4only)); rc = nn_iface_resolve (nn_chunkref_data (&self->nic), nn_chunkref_size (&self->nic), ipv4only, &local, &locallen); if (nn_slow (rc < 0)) { nn_backoff_start (&self->retry); self->state = NN_CWS_STATE_WAITING; return; } /* Combine the remote address and the port. */ remote = *ss; remotelen = sslen; if (remote.ss_family == AF_INET) ((struct sockaddr_in*) &remote)->sin_port = htons (self->remote_port); else if (remote.ss_family == AF_INET6) ((struct sockaddr_in6*) &remote)->sin6_port = htons (self->remote_port); else nn_assert (0); /* Try to start the underlying socket. */ rc = nn_usock_start (&self->usock, remote.ss_family, SOCK_STREAM, 0); if (nn_slow (rc < 0)) { nn_backoff_start (&self->retry); self->state = NN_CWS_STATE_WAITING; return; } /* Set the relevant socket options. */ sz = sizeof (val); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_SNDBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&self->usock, SOL_SOCKET, SO_SNDBUF, &val, sizeof (val)); sz = sizeof (val); nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_RCVBUF, &val, &sz); nn_assert (sz == sizeof (val)); nn_usock_setsockopt (&self->usock, SOL_SOCKET, SO_RCVBUF, &val, sizeof (val)); /* Bind the socket to the local network interface. */ rc = nn_usock_bind (&self->usock, (struct sockaddr*) &local, locallen); errnum_assert (rc == 0, -rc); /* Start connecting. */ nn_usock_connect (&self->usock, (struct sockaddr*) &remote, remotelen); self->state = NN_CWS_STATE_CONNECTING; nn_epbase_stat_increment (&self->epbase, NN_STAT_INPROGRESS_CONNECTIONS, 1); } nanomsg-0.8-beta/src/transports/ws/sws.h0000664000175000017500000001556112623652600021276 0ustar00travistravis00000000000000/* Copyright (c) 2013 250bpm s.r.o. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. All rights reserved. Copyright 2015 Garrett D'Amore 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. */ #ifndef NN_SWS_INCLUDED #define NN_SWS_INCLUDED #include "../../transport.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "ws_handshake.h" #include "../../utils/msg.h" #include "../../utils/list.h" /* This state machine handles WebSocket connection from the point where it is established to the point when it is broken. */ /* Return codes of this state machine. */ #define NN_SWS_RETURN_ERROR 1 #define NN_SWS_RETURN_CLOSE_HANDSHAKE 2 #define NN_SWS_RETURN_STOPPED 3 /* WebSocket protocol header frame sizes. */ #define NN_SWS_FRAME_SIZE_INITIAL 2 #define NN_SWS_FRAME_SIZE_PAYLOAD_0 0 #define NN_SWS_FRAME_SIZE_PAYLOAD_16 2 #define NN_SWS_FRAME_SIZE_PAYLOAD_63 8 #define NN_SWS_FRAME_SIZE_MASK 4 /* WebSocket control bitmasks as per RFC 6455 5.2. */ #define NN_SWS_FRAME_BITMASK_FIN 0x80 #define NN_SWS_FRAME_BITMASK_RSV1 0x40 #define NN_SWS_FRAME_BITMASK_RSV2 0x20 #define NN_SWS_FRAME_BITMASK_RSV3 0x10 #define NN_SWS_FRAME_BITMASK_OPCODE 0x0F /* UTF-8 validation. */ #define NN_SWS_UTF8_MAX_CODEPOINT_LEN 4 /* The longest possible header frame length. As per RFC 6455 5.2: first 2 bytes of initial framing + up to 8 bytes of additional extended payload length header + 4 byte mask = 14bytes Not all messages will use the maximum amount allocated, but statically allocating this buffer for convenience. */ #define NN_SWS_FRAME_MAX_HDR_LEN 14 /* WebSocket protocol payload length framing RFC 6455 section 5.2. */ #define NN_SWS_PAYLOAD_MAX_LENGTH 125 #define NN_SWS_PAYLOAD_MAX_LENGTH_16 65535 #define NN_SWS_PAYLOAD_MAX_LENGTH_63 9223372036854775807 #define NN_SWS_PAYLOAD_FRAME_16 0x7E #define NN_SWS_PAYLOAD_FRAME_63 0x7F /* WebSocket Close Status Code length. */ #define NN_SWS_CLOSE_CODE_LEN 2 struct nn_sws { /* The state machine. */ struct nn_fsm fsm; int state; /* Endpoint base. */ struct nn_epbase *epbase; /* Default message type set on outbound frames. */ uint8_t msg_type; /* Controls Tx/Rx framing based on whether this peer is acting as a Client or a Server. */ int mode; /* The underlying socket. */ struct nn_usock *usock; /* Child state machine to do protocol header exchange. */ struct nn_ws_handshake handshaker; /* The original owner of the underlying socket. */ struct nn_fsm_owner usock_owner; /* Pipe connecting this WebSocket connection to the nanomsg core. */ struct nn_pipebase pipebase; /* Requested resource when acting as client. */ const char* resource; /* Remote Host in header request when acting as client. */ const char* remote_host; /* State of inbound state machine. */ int instate; /* Buffer used to store the framing of incoming message. */ uint8_t inhdr [NN_SWS_FRAME_MAX_HDR_LEN]; /* Parsed header frames. */ uint8_t opcode; uint8_t payload_ctl; uint8_t masked; uint8_t *mask; size_t ext_hdr_len; int is_final_frame; int is_control_frame; /* As valid fragments are being received, this flag stays true until the FIN bit is received. This state is also used to determine peer sequencing anamolies that trigger this endpoint to fail the connection. */ int continuing; /* When validating continuation frames of UTF-8, it may be necessary to buffer tail-end of the previous frame in order to continue validation in the case that frames are chopped on intra-code point boundaries. */ uint8_t utf8_code_pt_fragment [NN_SWS_UTF8_MAX_CODEPOINT_LEN]; size_t utf8_code_pt_fragment_len; /* Statistics on control frames. */ int pings_sent; int pongs_sent; int pings_received; int pongs_received; /* Fragments of message being received at the moment. */ struct nn_list inmsg_array; uint8_t *inmsg_current_chunk_buf; size_t inmsg_current_chunk_len; size_t inmsg_total_size; int inmsg_chunks; uint8_t inmsg_hdr; /* Control message being received at the moment. Because these can be interspersed between fragmented TEXT and BINARY messages, they are stored in this buffer so as not to interrupt the message array. */ uint8_t inmsg_control [NN_SWS_PAYLOAD_MAX_LENGTH]; /* Reason this connection is closing to send as closing handshake. */ char fail_msg [NN_SWS_PAYLOAD_MAX_LENGTH]; size_t fail_msg_len; /* State of the outbound state machine. */ int outstate; /* Buffer used to store the header of outgoing message. */ uint8_t outhdr [NN_SWS_FRAME_MAX_HDR_LEN]; /* Message being sent at the moment. */ struct nn_msg outmsg; /* Event raised when the state machine ends. */ struct nn_fsm_event done; }; /* Scatter/gather array element type forincoming message chunks. Fragmented message frames are reassembled prior to notifying the user. */ struct msg_chunk { struct nn_list_item item; struct nn_chunkref chunk; }; /* Allocate a new message chunk, append it to message array, and return pointer to its buffer. */ void *nn_msg_chunk_new (size_t size, struct nn_list *msg_array); /* Deallocate a message chunk and remove it from array. */ void nn_msg_chunk_term (struct msg_chunk *it, struct nn_list *msg_array); /* Deallocate an entire message array. */ void nn_msg_array_term (struct nn_list *msg_array); void nn_sws_init (struct nn_sws *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner); void nn_sws_term (struct nn_sws *self); int nn_sws_isidle (struct nn_sws *self); void nn_sws_start (struct nn_sws *self, struct nn_usock *usock, int mode, const char *resource, const char *host, uint8_t msg_type); void nn_sws_stop (struct nn_sws *self); #endif nanomsg-0.8-beta/src/transports/ws/sws.c0000664000175000017500000015634312623652600021275 0ustar00travistravis00000000000000/* Copyright (c) 2013 250bpm s.r.o. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. All rights reserved. Copyright 2015 Garrett D'Amore 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 "sws.h" #include "../../ws.h" #include "../../nn.h" #include "../../utils/alloc.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/wire.h" #include "../../utils/int.h" #include "../../utils/attr.h" #include "../../utils/random.h" /* States of the object as a whole. */ #define NN_SWS_STATE_IDLE 1 #define NN_SWS_STATE_HANDSHAKE 2 #define NN_SWS_STATE_STOPPING_HANDSHAKE 3 #define NN_SWS_STATE_ACTIVE 4 #define NN_SWS_STATE_CLOSING_CONNECTION 5 #define NN_SWS_STATE_BROKEN_CONNECTION 6 #define NN_SWS_STATE_DONE 7 #define NN_SWS_STATE_STOPPING 8 /* Possible states of the inbound part of the object. */ #define NN_SWS_INSTATE_RECV_HDR 1 #define NN_SWS_INSTATE_RECV_HDREXT 2 #define NN_SWS_INSTATE_RECV_PAYLOAD 3 #define NN_SWS_INSTATE_RECVD_CHUNKED 4 #define NN_SWS_INSTATE_RECVD_CONTROL 5 #define NN_SWS_INSTATE_FAILING 6 #define NN_SWS_INSTATE_CLOSED 7 /* Possible states of the outbound part of the object. */ #define NN_SWS_OUTSTATE_IDLE 1 #define NN_SWS_OUTSTATE_SENDING 2 /* Subordinate srcptr objects. */ #define NN_SWS_SRC_USOCK 1 #define NN_SWS_SRC_HANDSHAKE 2 /* WebSocket opcode constants as per RFC 6455 5.2. */ #define NN_WS_OPCODE_FRAGMENT 0x00 #define NN_WS_OPCODE_TEXT NN_WS_MSG_TYPE_TEXT #define NN_WS_OPCODE_BINARY NN_WS_MSG_TYPE_BINARY #define NN_WS_OPCODE_UNUSED3 0x03 #define NN_WS_OPCODE_UNUSED4 0x04 #define NN_WS_OPCODE_UNUSED5 0x05 #define NN_WS_OPCODE_UNUSED6 0x06 #define NN_WS_OPCODE_UNUSED7 0x07 #define NN_WS_OPCODE_CLOSE 0x08 #define NN_WS_OPCODE_PING 0x09 #define NN_WS_OPCODE_PONG 0x0A #define NN_WS_OPCODE_UNUSEDB 0x0B #define NN_WS_OPCODE_UNUSEDC 0x0C #define NN_WS_OPCODE_UNUSEDD 0x0D #define NN_WS_OPCODE_UNUSEDE 0x0E #define NN_WS_OPCODE_UNUSEDF 0x0F /* WebSocket protocol header bit masks as per RFC 6455. */ #define NN_SWS_FRAME_BITMASK_MASKED 0x80 #define NN_SWS_FRAME_BITMASK_NOT_MASKED 0x00 #define NN_SWS_FRAME_BITMASK_LENGTH 0x7F /* WebSocket Close Status Codes (1004-1006 and 1015 are reserved). */ #define NN_SWS_CLOSE_NORMAL 1000 #define NN_SWS_CLOSE_GOING_AWAY 1001 #define NN_SWS_CLOSE_ERR_PROTO 1002 #define NN_SWS_CLOSE_ERR_WUT 1003 #define NN_SWS_CLOSE_ERR_INVALID_FRAME 1007 #define NN_SWS_CLOSE_ERR_POLICY 1008 #define NN_SWS_CLOSE_ERR_TOOBIG 1009 #define NN_SWS_CLOSE_ERR_EXTENSION 1010 #define NN_SWS_CLOSE_ERR_SERVER 1011 /* UTF-8 validation. */ #define NN_SWS_UTF8_INVALID -2 #define NN_SWS_UTF8_FRAGMENT -1 /* Stream is a special type of pipe. Implementation of the virtual pipe API. */ static int nn_sws_send (struct nn_pipebase *self, struct nn_msg *msg); static int nn_sws_recv (struct nn_pipebase *self, struct nn_msg *msg); const struct nn_pipebase_vfptr nn_sws_pipebase_vfptr = { nn_sws_send, nn_sws_recv }; /* Private functions. */ static void nn_sws_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_sws_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); /* Ceases further I/O on the underlying socket and prepares to send a close handshake on the next receive. */ static int nn_sws_fail_conn (struct nn_sws *self, int code, char *reason); /* Start receiving new message chunk. */ static int nn_sws_recv_hdr (struct nn_sws *self); /* Mask or unmask message payload. */ static void nn_sws_mask_payload (uint8_t *payload, size_t payload_len, const uint8_t *mask, size_t mask_len, int *mask_start_pos); /* Validates incoming text chunks for UTF-8 compliance as per RFC 3629. */ static void nn_sws_validate_utf8_chunk (struct nn_sws *self); void nn_sws_init (struct nn_sws *self, int src, struct nn_epbase *epbase, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_sws_handler, nn_sws_shutdown, src, self, owner); self->state = NN_SWS_STATE_IDLE; self->epbase = epbase; nn_ws_handshake_init (&self->handshaker, NN_SWS_SRC_HANDSHAKE, &self->fsm); self->usock = NULL; self->usock_owner.src = -1; self->usock_owner.fsm = NULL; nn_pipebase_init (&self->pipebase, &nn_sws_pipebase_vfptr, epbase); self->instate = -1; nn_list_init (&self->inmsg_array); self->outstate = -1; nn_msg_init (&self->outmsg, 0); self->continuing = 0; memset (self->utf8_code_pt_fragment, 0, NN_SWS_UTF8_MAX_CODEPOINT_LEN); self->utf8_code_pt_fragment_len = 0; self->pings_sent = 0; self->pongs_sent = 0; self->pings_received = 0; self->pongs_received = 0; nn_fsm_event_init (&self->done); } void nn_sws_term (struct nn_sws *self) { nn_assert_state (self, NN_SWS_STATE_IDLE); nn_fsm_event_term (&self->done); nn_msg_term (&self->outmsg); nn_msg_array_term (&self->inmsg_array); nn_pipebase_term (&self->pipebase); nn_ws_handshake_term (&self->handshaker); nn_fsm_term (&self->fsm); } int nn_sws_isidle (struct nn_sws *self) { return nn_fsm_isidle (&self->fsm); } void nn_sws_start (struct nn_sws *self, struct nn_usock *usock, int mode, const char *resource, const char *host, uint8_t msg_type) { /* Take ownership of the underlying socket. */ nn_assert (self->usock == NULL && self->usock_owner.fsm == NULL); self->usock_owner.src = NN_SWS_SRC_USOCK; self->usock_owner.fsm = &self->fsm; nn_usock_swap_owner (usock, &self->usock_owner); self->usock = usock; self->mode = mode; self->resource = resource; self->remote_host = host; self->msg_type = msg_type; /* Launch the state machine. */ nn_fsm_start (&self->fsm); } void nn_sws_stop (struct nn_sws *self) { nn_fsm_stop (&self->fsm); } void *nn_msg_chunk_new (size_t size, struct nn_list *msg_array) { struct msg_chunk *self; self = nn_alloc (sizeof (struct msg_chunk), "msg_chunk"); alloc_assert (self); nn_chunkref_init (&self->chunk, size); nn_list_item_init (&self->item); nn_list_insert (msg_array, &self->item, nn_list_end (msg_array)); return nn_chunkref_data (&self->chunk); } void nn_msg_chunk_term (struct msg_chunk *it, struct nn_list *msg_array) { nn_chunkref_term (&it->chunk); nn_list_erase (msg_array, &it->item); nn_list_item_term (&it->item); nn_free (it); } void nn_msg_array_term (struct nn_list *msg_array) { struct nn_list_item *it; struct msg_chunk *ch; while (!nn_list_empty (msg_array)) { it = nn_list_begin (msg_array); ch = nn_cont (it, struct msg_chunk, item); nn_msg_chunk_term (ch, msg_array); } nn_list_term (msg_array); } static int nn_utf8_code_point (const uint8_t *buffer, size_t len) { /* The lack of information is considered neither valid nor invalid. */ if (!buffer || !len) return NN_SWS_UTF8_FRAGMENT; /* RFC 3629 section 4 UTF8-1. */ if (buffer [0] <= 0x7F) return 1; /* 0xC2, or 11000001, is the smallest conceivable multi-octet code point that is not an illegal overlong encoding. */ if (buffer [0] < 0xC2) return NN_SWS_UTF8_INVALID; /* Largest 2-octet code point starts with 0xDF (11011111). */ if (buffer [0] <= 0xDF) { if (len < 2) return NN_SWS_UTF8_FRAGMENT; /* Ensure continuation byte in form of 10xxxxxx */ else if ((buffer [1] & 0xC0) != 0x80) return NN_SWS_UTF8_INVALID; else return 2; } /* RFC 3629 section 4 UTF8-3, where 0xEF is 11101111. */ if (buffer [0] <= 0xEF) { /* Fragment. */ if (len < 2) return NN_SWS_UTF8_FRAGMENT; /* Illegal overlong sequence detection. */ else if (buffer [0] == 0xE0 && (buffer [1] < 0xA0 || buffer [1] == 0x80)) return NN_SWS_UTF8_INVALID; /* Illegal UTF-16 surrogate pair half U+D800 through U+DFFF. */ else if (buffer [0] == 0xED && buffer [1] >= 0xA0) return NN_SWS_UTF8_INVALID; /* Fragment. */ else if (len < 3) return NN_SWS_UTF8_FRAGMENT; /* Ensure continuation bytes 2 and 3 in form of 10xxxxxx */ else if ((buffer [1] & 0xC0) != 0x80 || (buffer [2] & 0xC0) != 0x80) return NN_SWS_UTF8_INVALID; else return 3; } /* RFC 3629 section 4 UTF8-4, where 0xF4 is 11110100. Why not 11110111 to follow the pattern? Because UTF-8 encoding stops at 0x10FFFF as per RFC 3629. */ if (buffer [0] <= 0xF4) { /* Fragment. */ if (len < 2) return NN_SWS_UTF8_FRAGMENT; /* Illegal overlong sequence detection. */ else if (buffer [0] == 0xF0 && buffer [1] < 0x90) return NN_SWS_UTF8_INVALID; /* Illegal code point greater than U+10FFFF. */ else if (buffer [0] == 0xF4 && buffer [1] >= 0x90) return NN_SWS_UTF8_INVALID; /* Fragment. */ else if (len < 4) return NN_SWS_UTF8_FRAGMENT; /* Ensure continuation bytes 2, 3, and 4 in form of 10xxxxxx */ else if ((buffer [1] & 0xC0) != 0x80 || (buffer [2] & 0xC0) != 0x80 || (buffer [3] & 0xC0) != 0x80) return NN_SWS_UTF8_INVALID; else return 4; } /* UTF-8 encoding stops at U+10FFFF and only defines up to 4-octet code point sequences. */ if (buffer [0] >= 0xF5) return NN_SWS_UTF8_INVALID; /* Algorithm error; a case above should have been satisfied. */ nn_assert (0); } static void nn_sws_mask_payload (uint8_t *payload, size_t payload_len, const uint8_t *mask, size_t mask_len, int *mask_start_pos) { unsigned i; if (mask_start_pos) { for (i = 0; i < payload_len; i++) { payload [i] ^= mask [(i + *mask_start_pos) % mask_len]; } *mask_start_pos = (i + *mask_start_pos) % mask_len; return; } else { for (i = 0; i < payload_len; i++) { payload [i] ^= mask [i % mask_len]; } return; } } static int nn_sws_recv_hdr (struct nn_sws *self) { if (!self->continuing) { nn_assert (nn_list_empty (&self->inmsg_array)); self->inmsg_current_chunk_buf = NULL; self->inmsg_chunks = 0; self->inmsg_current_chunk_len = 0; self->inmsg_total_size = 0; } memset (self->inmsg_control, 0, NN_SWS_PAYLOAD_MAX_LENGTH); memset (self->inhdr, 0, NN_SWS_FRAME_MAX_HDR_LEN); self->instate = NN_SWS_INSTATE_RECV_HDR; nn_usock_recv (self->usock, self->inhdr, NN_SWS_FRAME_SIZE_INITIAL, NULL); return 0; } static int nn_sws_send (struct nn_pipebase *self, struct nn_msg *msg) { struct nn_sws *sws; struct nn_iovec iov [3]; int mask_pos; size_t nn_msg_size; size_t hdr_len; struct nn_cmsghdr *cmsg; struct nn_msghdr msghdr; uint8_t rand_mask [NN_SWS_FRAME_SIZE_MASK]; sws = nn_cont (self, struct nn_sws, pipebase); nn_assert_state (sws, NN_SWS_STATE_ACTIVE); nn_assert (sws->outstate == NN_SWS_OUTSTATE_IDLE); /* Move the message to the local storage. */ nn_msg_term (&sws->outmsg); nn_msg_mv (&sws->outmsg, msg); memset (sws->outhdr, 0, sizeof (sws->outhdr)); hdr_len = NN_SWS_FRAME_SIZE_INITIAL; cmsg = NULL; msghdr.msg_iov = NULL; msghdr.msg_iovlen = 0; msghdr.msg_controllen = nn_chunkref_size (&sws->outmsg.hdrs); /* If the outgoing message has specified an opcode and control framing in its header, properly frame it as per RFC 6455 5.2. */ if (msghdr.msg_controllen > 0) { msghdr.msg_control = nn_chunkref_data (&sws->outmsg.hdrs); cmsg = NN_CMSG_FIRSTHDR (&msghdr); while (cmsg) { if (cmsg->cmsg_level == NN_WS && cmsg->cmsg_type == NN_WS_MSG_TYPE) break; cmsg = NN_CMSG_NXTHDR (&msghdr, cmsg); } } /* If the header does not specify an opcode, take default from option. */ if (cmsg) sws->outhdr [0] = *(uint8_t *) NN_CMSG_DATA (cmsg); else sws->outhdr [0] = sws->msg_type; /* For now, enforce that outgoing messages are the final frame. */ sws->outhdr [0] |= NN_SWS_FRAME_BITMASK_FIN; nn_msg_size = nn_chunkref_size (&sws->outmsg.sphdr) + nn_chunkref_size (&sws->outmsg.body); /* Framing WebSocket payload size in network byte order (big endian). */ if (nn_msg_size <= NN_SWS_PAYLOAD_MAX_LENGTH) { sws->outhdr [1] |= (uint8_t) nn_msg_size; hdr_len += NN_SWS_FRAME_SIZE_PAYLOAD_0; } else if (nn_msg_size <= NN_SWS_PAYLOAD_MAX_LENGTH_16) { sws->outhdr [1] |= NN_SWS_PAYLOAD_FRAME_16; nn_puts (&sws->outhdr [hdr_len], (uint16_t) nn_msg_size); hdr_len += NN_SWS_FRAME_SIZE_PAYLOAD_16; } else { sws->outhdr [1] |= NN_SWS_PAYLOAD_FRAME_63; nn_putll (&sws->outhdr [hdr_len], (uint64_t) nn_msg_size); hdr_len += NN_SWS_FRAME_SIZE_PAYLOAD_63; } if (sws->mode == NN_WS_CLIENT) { sws->outhdr [1] |= NN_SWS_FRAME_BITMASK_MASKED; /* Generate 32-bit mask as per RFC 6455 5.3. */ nn_random_generate (rand_mask, NN_SWS_FRAME_SIZE_MASK); memcpy (&sws->outhdr [hdr_len], rand_mask, NN_SWS_FRAME_SIZE_MASK); hdr_len += NN_SWS_FRAME_SIZE_MASK; /* Mask payload, beginning with header and moving to body. */ mask_pos = 0; nn_sws_mask_payload (nn_chunkref_data (&sws->outmsg.sphdr), nn_chunkref_size (&sws->outmsg.sphdr), rand_mask, NN_SWS_FRAME_SIZE_MASK, &mask_pos); nn_sws_mask_payload (nn_chunkref_data (&sws->outmsg.body), nn_chunkref_size (&sws->outmsg.body), rand_mask, NN_SWS_FRAME_SIZE_MASK, &mask_pos); } else if (sws->mode == NN_WS_SERVER) { sws->outhdr [1] |= NN_SWS_FRAME_BITMASK_NOT_MASKED; } else { /* Developer error; sws object was not constructed properly. */ nn_assert (0); } /* Start async sending. */ iov [0].iov_base = sws->outhdr; iov [0].iov_len = hdr_len; iov [1].iov_base = nn_chunkref_data (&sws->outmsg.sphdr); iov [1].iov_len = nn_chunkref_size (&sws->outmsg.sphdr); iov [2].iov_base = nn_chunkref_data (&sws->outmsg.body); iov [2].iov_len = nn_chunkref_size (&sws->outmsg.body); nn_usock_send (sws->usock, iov, 3); sws->outstate = NN_SWS_OUTSTATE_SENDING; /* If a Close handshake was just sent, it's time to shut down. */ if ((sws->outhdr [0] & NN_SWS_FRAME_BITMASK_OPCODE) == NN_WS_OPCODE_CLOSE) { nn_pipebase_stop (&sws->pipebase); sws->state = NN_SWS_STATE_CLOSING_CONNECTION; } return 0; } static int nn_sws_recv (struct nn_pipebase *self, struct nn_msg *msg) { struct nn_sws *sws; struct nn_list_item *it; struct msg_chunk *ch; struct nn_cmsghdr *cmsg; uint8_t opcode_hdr; size_t cmsgsz; size_t pos; sws = nn_cont (self, struct nn_sws, pipebase); nn_assert_state (sws, NN_SWS_STATE_ACTIVE); switch (sws->instate) { case NN_SWS_INSTATE_RECVD_CHUNKED: /* This library should not deliver fragmented messages to the application, so it's expected that this is the final frame. */ nn_assert (sws->is_final_frame); nn_msg_init (msg, sws->inmsg_total_size); /* Relay opcode to the user in order to interpret payload. */ opcode_hdr = sws->inmsg_hdr; pos = 0; /* Reassemble incoming message scatter array. */ while (!nn_list_empty (&sws->inmsg_array)) { it = nn_list_begin (&sws->inmsg_array); ch = nn_cont (it, struct msg_chunk, item); memcpy (((uint8_t*) nn_chunkref_data (&msg->body)) + pos, nn_chunkref_data (&ch->chunk), nn_chunkref_size (&ch->chunk)); pos += nn_chunkref_size (&ch->chunk); nn_msg_chunk_term (ch, &sws->inmsg_array); } nn_assert (pos == sws->inmsg_total_size); nn_assert (nn_list_empty (&sws->inmsg_array)); /* No longer collecting scatter array of incoming msg chunks. */ sws->continuing = 0; nn_sws_recv_hdr (sws); break; case NN_SWS_INSTATE_RECVD_CONTROL: /* This library should not deliver fragmented messages to the user, so it's expected that this is the final frame. */ nn_assert (sws->is_final_frame); nn_msg_init (msg, sws->inmsg_current_chunk_len); /* Relay opcode to the user in order to interpret payload. */ opcode_hdr = sws->inhdr [0]; memcpy (((uint8_t*) nn_chunkref_data (&msg->body)), sws->inmsg_control, sws->inmsg_current_chunk_len); /* If a closing handshake was just transferred to the application, discontinue continual, async receives. */ if (sws->opcode == NN_WS_OPCODE_CLOSE) { sws->instate = NN_SWS_INSTATE_CLOSED; } else { nn_sws_recv_hdr (sws); } break; default: /* Unexpected state. */ nn_assert (0); break; } /* Allocate and populate WebSocket-specific control headers. */ cmsgsz = NN_CMSG_SPACE (sizeof (opcode_hdr)); nn_chunkref_init (&msg->hdrs, cmsgsz); cmsg = nn_chunkref_data (&msg->hdrs); cmsg->cmsg_level = NN_WS; cmsg->cmsg_type = NN_WS_MSG_TYPE; cmsg->cmsg_len = cmsgsz; memcpy (NN_CMSG_DATA (cmsg), &opcode_hdr, sizeof (opcode_hdr)); return 0; } static void nn_sws_validate_utf8_chunk (struct nn_sws *self) { uint8_t *pos; int code_point_len; int len; len = self->inmsg_current_chunk_len; pos = self->inmsg_current_chunk_buf; /* For chunked transfers, it's possible that a previous chunk was cut intra-code point. That partially-validated code point is reassembled with the beginning of the current chunk and checked. */ if (self->utf8_code_pt_fragment_len) { nn_assert (self->utf8_code_pt_fragment_len < NN_SWS_UTF8_MAX_CODEPOINT_LEN); /* Keep adding octets from fresh buffer to previous code point fragment to check for validity. */ while (len > 0) { self->utf8_code_pt_fragment [self->utf8_code_pt_fragment_len] = *pos; self->utf8_code_pt_fragment_len++; pos++; len--; code_point_len = nn_utf8_code_point (self->utf8_code_pt_fragment, self->utf8_code_pt_fragment_len); if (code_point_len > 0) { /* Valid code point found; continue validating. */ break; } else if (code_point_len == NN_SWS_UTF8_INVALID) { nn_sws_fail_conn (self, NN_SWS_CLOSE_ERR_INVALID_FRAME, "Invalid UTF-8 code point split on previous frame."); return; } else if (code_point_len == NN_SWS_UTF8_FRAGMENT) { if (self->is_final_frame) { nn_sws_fail_conn (self, NN_SWS_CLOSE_ERR_INVALID_FRAME, "Truncated UTF-8 payload with invalid code point."); return; } else { /* This chunk is well-formed; now recv the next chunk. */ nn_sws_recv_hdr (self); return; } } } } if (self->utf8_code_pt_fragment_len >= NN_SWS_UTF8_MAX_CODEPOINT_LEN) nn_assert (0); while (len > 0) { code_point_len = nn_utf8_code_point (pos, len); if (code_point_len > 0) { /* Valid code point found; continue validating. */ pos += code_point_len; len -= code_point_len; nn_assert (len >= 0); continue; } else if (code_point_len == NN_SWS_UTF8_INVALID) { self->utf8_code_pt_fragment_len = 0; memset (self->utf8_code_pt_fragment, 0, NN_SWS_UTF8_MAX_CODEPOINT_LEN); nn_sws_fail_conn (self, NN_SWS_CLOSE_ERR_INVALID_FRAME, "Invalid UTF-8 code point in payload."); return; } else if (code_point_len == NN_SWS_UTF8_FRAGMENT) { nn_assert (len < NN_SWS_UTF8_MAX_CODEPOINT_LEN); self->utf8_code_pt_fragment_len = len; memcpy (self->utf8_code_pt_fragment, pos, len); if (self->is_final_frame) { nn_sws_fail_conn (self, NN_SWS_CLOSE_ERR_INVALID_FRAME, "Truncated UTF-8 payload with invalid code point."); } else { /* Previous frame ended in the middle of a code point; receive more. */ nn_sws_recv_hdr (self); } return; } } /* Entire buffer is well-formed. */ nn_assert (len == 0); self->utf8_code_pt_fragment_len = 0; memset (self->utf8_code_pt_fragment, 0, NN_SWS_UTF8_MAX_CODEPOINT_LEN); if (self->is_final_frame) { self->instate = NN_SWS_INSTATE_RECVD_CHUNKED; nn_pipebase_received (&self->pipebase); } else { nn_sws_recv_hdr (self); } return; } static int nn_sws_fail_conn (struct nn_sws *self, int code, char *reason) { size_t reason_len; size_t payload_len; uint8_t rand_mask [NN_SWS_FRAME_SIZE_MASK]; uint8_t *payload_pos; struct nn_iovec iov; nn_assert_state (self, NN_SWS_STATE_ACTIVE); /* Destroy any remnant incoming message fragments. */ nn_msg_array_term (&self->inmsg_array); reason_len = strlen (reason); payload_len = reason_len + NN_SWS_CLOSE_CODE_LEN; /* Ensure text is short enough to also include code and framing. */ nn_assert (payload_len <= NN_SWS_PAYLOAD_MAX_LENGTH); /* RFC 6455 section 5.5.1. */ self->fail_msg [0] = NN_SWS_FRAME_BITMASK_FIN | NN_WS_OPCODE_CLOSE; /* Size of the payload, which is the status code plus the reason. */ self->fail_msg [1] = (char)payload_len; self->fail_msg_len = NN_SWS_FRAME_SIZE_INITIAL; switch (self->mode) { case NN_WS_SERVER: self->fail_msg [1] |= NN_SWS_FRAME_BITMASK_NOT_MASKED; break; case NN_WS_CLIENT: self->fail_msg [1] |= NN_SWS_FRAME_BITMASK_MASKED; /* Generate 32-bit mask as per RFC 6455 5.3. */ nn_random_generate (rand_mask, NN_SWS_FRAME_SIZE_MASK); memcpy (&self->fail_msg [NN_SWS_FRAME_SIZE_INITIAL], rand_mask, NN_SWS_FRAME_SIZE_MASK); self->fail_msg_len += NN_SWS_FRAME_SIZE_MASK; break; default: /* Developer error. */ nn_assert (0); } payload_pos = (uint8_t*) (&self->fail_msg [self->fail_msg_len]); /* Copy Status Code in network order (big-endian). */ nn_puts (payload_pos, (uint16_t) code); self->fail_msg_len += NN_SWS_CLOSE_CODE_LEN; /* Copy Close Reason immediately following the code. */ memcpy (payload_pos + NN_SWS_CLOSE_CODE_LEN, reason, reason_len); /* If this is a client, apply mask. */ if (self->mode == NN_WS_CLIENT) { nn_sws_mask_payload (payload_pos, payload_len, rand_mask, NN_SWS_FRAME_SIZE_MASK, NULL); } self->fail_msg_len += payload_len; self->instate = NN_SWS_INSTATE_CLOSED; /* Stop user send/recv actions. */ nn_pipebase_stop (&self->pipebase); if (self->outstate == NN_SWS_OUTSTATE_IDLE) { iov.iov_base = self->fail_msg; iov.iov_len = self->fail_msg_len; nn_usock_send (self->usock, &iov, 1); self->outstate = NN_SWS_OUTSTATE_SENDING; self->state = NN_SWS_STATE_CLOSING_CONNECTION; } else { self->state = NN_SWS_STATE_DONE; nn_fsm_raise (&self->fsm, &self->done, NN_SWS_RETURN_CLOSE_HANDSHAKE); } return 0; } static void nn_sws_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_sws *sws; sws = nn_cont (self, struct nn_sws, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { /* TODO: Consider sending a close code here? */ nn_pipebase_stop (&sws->pipebase); nn_ws_handshake_stop (&sws->handshaker); sws->state = NN_SWS_STATE_STOPPING; } if (nn_slow (sws->state == NN_SWS_STATE_STOPPING)) { if (nn_ws_handshake_isidle (&sws->handshaker)) { nn_usock_swap_owner (sws->usock, &sws->usock_owner); sws->usock = NULL; sws->usock_owner.src = -1; sws->usock_owner.fsm = NULL; sws->state = NN_SWS_STATE_IDLE; nn_fsm_stopped (&sws->fsm, NN_SWS_RETURN_STOPPED); return; } return; } nn_fsm_bad_state (sws->state, src, type); } static void nn_sws_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_sws *sws; int rc; sws = nn_cont (self, struct nn_sws, fsm); switch (sws->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_SWS_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_ws_handshake_start (&sws->handshaker, sws->usock, &sws->pipebase, sws->mode, sws->resource, sws->remote_host); sws->state = NN_SWS_STATE_HANDSHAKE; return; default: nn_fsm_bad_action (sws->state, src, type); } default: nn_fsm_bad_source (sws->state, src, type); } /******************************************************************************/ /* HANDSHAKE state. */ /******************************************************************************/ case NN_SWS_STATE_HANDSHAKE: switch (src) { case NN_SWS_SRC_HANDSHAKE: switch (type) { case NN_WS_HANDSHAKE_OK: /* Before moving to the active state stop the handshake state machine. */ nn_ws_handshake_stop (&sws->handshaker); sws->state = NN_SWS_STATE_STOPPING_HANDSHAKE; return; case NN_WS_HANDSHAKE_ERROR: /* Raise the error and move directly to the DONE state. ws_handshake object will be stopped later on. */ sws->state = NN_SWS_STATE_DONE; nn_fsm_raise (&sws->fsm, &sws->done, NN_SWS_RETURN_CLOSE_HANDSHAKE); return; default: nn_fsm_bad_action (sws->state, src, type); } default: nn_fsm_bad_source (sws->state, src, type); } /******************************************************************************/ /* STOPPING_HANDSHAKE state. */ /******************************************************************************/ case NN_SWS_STATE_STOPPING_HANDSHAKE: switch (src) { case NN_SWS_SRC_HANDSHAKE: switch (type) { case NN_WS_HANDSHAKE_STOPPED: /* Start the pipe. */ rc = nn_pipebase_start (&sws->pipebase); if (nn_slow (rc < 0)) { sws->state = NN_SWS_STATE_DONE; nn_fsm_raise (&sws->fsm, &sws->done, NN_SWS_RETURN_ERROR); return; } /* Start receiving a message in asynchronous manner. */ nn_sws_recv_hdr (sws); /* Mark the pipe as available for sending. */ sws->outstate = NN_SWS_OUTSTATE_IDLE; sws->state = NN_SWS_STATE_ACTIVE; return; default: nn_fsm_bad_action (sws->state, src, type); } default: nn_fsm_bad_source (sws->state, src, type); } /******************************************************************************/ /* ACTIVE state. */ /******************************************************************************/ case NN_SWS_STATE_ACTIVE: switch (src) { case NN_SWS_SRC_USOCK: switch (type) { case NN_USOCK_SENT: /* The message is now fully sent. */ nn_assert (sws->outstate == NN_SWS_OUTSTATE_SENDING); sws->outstate = NN_SWS_OUTSTATE_IDLE; nn_msg_term (&sws->outmsg); nn_msg_init (&sws->outmsg, 0); nn_pipebase_sent (&sws->pipebase); return; case NN_USOCK_RECEIVED: switch (sws->instate) { case NN_SWS_INSTATE_RECV_HDR: /* Require RSV1, RSV2, and RSV3 bits to be unset for x-nanomsg protocol as per RFC 6455 section 5.2. */ if (sws->inhdr [0] & NN_SWS_FRAME_BITMASK_RSV1 || sws->inhdr [0] & NN_SWS_FRAME_BITMASK_RSV2 || sws->inhdr [0] & NN_SWS_FRAME_BITMASK_RSV3) { nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "RSV1, RSV2, and RSV3 must be unset."); return; } sws->is_final_frame = sws->inhdr [0] & NN_SWS_FRAME_BITMASK_FIN; sws->masked = sws->inhdr [1] & NN_SWS_FRAME_BITMASK_MASKED; switch (sws->mode) { case NN_WS_SERVER: /* Require mask bit to be set from client. */ if (sws->masked) { /* Continue receiving header for this frame. */ sws->ext_hdr_len = NN_SWS_FRAME_SIZE_MASK; break; } else { nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "Server expects MASK bit to be set."); return; } case NN_WS_CLIENT: /* Require mask bit to be unset from server. */ if (sws->masked) { nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "Client expects MASK bit to be unset."); return; } else { /* Continue receiving header for this frame. */ sws->ext_hdr_len = 0; break; } default: /* Only two modes of this endpoint are expected. */ nn_assert (0); return; } sws->opcode = sws->inhdr [0] & NN_SWS_FRAME_BITMASK_OPCODE; sws->payload_ctl = sws->inhdr [1] & NN_SWS_FRAME_BITMASK_LENGTH; /* Prevent unexpected continuation frame. */ if (!sws->continuing && sws->opcode == NN_WS_OPCODE_FRAGMENT) { nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "No message to continue."); return; } /* Preserve initial message opcode and RSV bits in case this is a fragmented message. */ if (!sws->continuing) sws->inmsg_hdr = sws->inhdr [0] | NN_SWS_FRAME_BITMASK_FIN; if (sws->payload_ctl <= NN_SWS_PAYLOAD_MAX_LENGTH) { sws->ext_hdr_len += NN_SWS_FRAME_SIZE_PAYLOAD_0; } else if (sws->payload_ctl == NN_SWS_PAYLOAD_FRAME_16) { sws->ext_hdr_len += NN_SWS_FRAME_SIZE_PAYLOAD_16; } else if (sws->payload_ctl == NN_SWS_PAYLOAD_FRAME_63) { sws->ext_hdr_len += NN_SWS_FRAME_SIZE_PAYLOAD_63; } else { /* Developer error parsing/handling length. */ nn_assert (0); return; } switch (sws->opcode) { case NN_WS_OPCODE_TEXT: /* Fall thru; TEXT and BINARY handled alike. */ case NN_WS_OPCODE_BINARY: sws->is_control_frame = 0; if (sws->continuing) { nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "Expected continuation frame opcode."); return; } if (!sws->is_final_frame) sws->continuing = 1; if (sws->ext_hdr_len == 0 && sws->payload_ctl == 0) { /* Only a remote server could send a 2-byte msg; sanity-check that this endpoint is a client. */ nn_assert (sws->mode == NN_WS_CLIENT); sws->inmsg_current_chunk_len = 0; if (sws->continuing) { /* This frame was empty, but continue next frame in fragmented sequence. */ nn_sws_recv_hdr (sws); return; } else { /* Special case when there is no payload, mask, or additional frames. */ sws->instate = NN_SWS_INSTATE_RECVD_CHUNKED; nn_pipebase_received (&sws->pipebase); return; } } /* Continue to receive extended header+payload. */ break; case NN_WS_OPCODE_FRAGMENT: sws->is_control_frame = 0; sws->continuing = !sws->is_final_frame; if (sws->ext_hdr_len == 0 && sws->payload_ctl == 0) { /* Only a remote server could send a 2-byte msg; sanity-check that this endpoint is a client. */ nn_assert (sws->mode == NN_WS_CLIENT); sws->inmsg_current_chunk_len = 0; if (sws->continuing) { /* This frame was empty, but continue next frame in fragmented sequence. */ nn_sws_recv_hdr (sws); return; } else { /* Special case when there is no payload, mask, or additional frames. */ sws->instate = NN_SWS_INSTATE_RECVD_CHUNKED; nn_pipebase_received (&sws->pipebase); return; } } /* Continue to receive extended header+payload. */ break; case NN_WS_OPCODE_PING: sws->is_control_frame = 1; sws->pings_received++; if (sws->payload_ctl > NN_SWS_PAYLOAD_MAX_LENGTH) { /* As per RFC 6455 section 5.4, large payloads on control frames is not allowed, and on receipt the endpoint MUST close connection immediately. */ nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "Control frame payload exceeds allowable length."); return; } if (!sws->is_final_frame) { /* As per RFC 6455 section 5.4, fragmentation of control frames is not allowed; on receipt the endpoint MUST close connection immediately. */ nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "Cannot fragment control message (FIN=0)."); return; } if (sws->ext_hdr_len == 0 && sws->payload_ctl == 0) { /* Special case when there is no payload, mask, or additional frames. */ sws->inmsg_current_chunk_len = 0; sws->instate = NN_SWS_INSTATE_RECVD_CONTROL; nn_pipebase_received (&sws->pipebase); return; } /* Continue to receive extended header+payload. */ break; case NN_WS_OPCODE_PONG: sws->is_control_frame = 1; sws->pongs_received++; if (sws->payload_ctl > NN_SWS_PAYLOAD_MAX_LENGTH) { /* As per RFC 6455 section 5.4, large payloads on control frames is not allowed, and on receipt the endpoint MUST close connection immediately. */ nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "Control frame payload exceeds allowable length."); return; } if (!sws->is_final_frame) { /* As per RFC 6455 section 5.4, fragmentation of control frames is not allowed; on receipt the endpoint MUST close connection immediately. */ nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "Cannot fragment control message (FIN=0)."); return; } if (sws->ext_hdr_len == 0 && sws->payload_ctl == 0) { /* Special case when there is no payload, mask, or additional frames. */ sws->inmsg_current_chunk_len = 0; sws->instate = NN_SWS_INSTATE_RECVD_CONTROL; nn_pipebase_received (&sws->pipebase); return; } /* Continue to receive extended header+payload. */ break; case NN_WS_OPCODE_CLOSE: /* RFC 6455 section 5.5.1. */ sws->is_control_frame = 1; if (!sws->is_final_frame) { /* As per RFC 6455 section 5.4, fragmentation of control frames is not allowed; on receipt the endpoint MUST close connection immediately. */ nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "Cannot fragment control message (FIN=0)."); return; } if (sws->payload_ctl > NN_SWS_PAYLOAD_MAX_LENGTH) { /* As per RFC 6455 section 5.4, large payloads on control frames is not allowed, and on receipt the endpoint MUST close connection immediately. */ nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "Control frame payload exceeds allowable length."); return; } if (sws->payload_ctl == 1) { /* As per RFC 6455 section 5.5.1, if a payload is to accompany a close frame, the first two bytes MUST be the close code. */ nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "Expected 2byte close code."); return; } if (sws->ext_hdr_len == 0 && sws->payload_ctl == 0) { /* Special case when there is no payload, mask, or additional frames. */ sws->inmsg_current_chunk_len = 0; sws->instate = NN_SWS_INSTATE_RECVD_CONTROL; nn_pipebase_received (&sws->pipebase); return; } /* Continue to receive extended header+payload. */ break; default: /* Client sent an invalid opcode; as per RFC 6455 section 10.7, close connection with code. */ nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "Invalid opcode."); return; } if (sws->ext_hdr_len == 0) { /* Only a remote server could send a 2-byte msg; sanity-check that this endpoint is a client. */ nn_assert (sws->mode == NN_WS_CLIENT); /* In the case of no additional header, the payload is known to not exceed this threshold. */ nn_assert (sws->payload_ctl <= NN_SWS_PAYLOAD_MAX_LENGTH); /* In the case of no additional header, the payload is known to not exceed this threshold. */ nn_assert (sws->payload_ctl > 0); sws->instate = NN_SWS_INSTATE_RECV_PAYLOAD; sws->inmsg_current_chunk_len = sws->payload_ctl; /* Use scatter/gather array for application messages, and a fixed-width buffer for control messages. This is convenient since control messages can be interspersed between chunked application msgs. */ if (sws->is_control_frame) { sws->inmsg_current_chunk_buf = sws->inmsg_control; } else { sws->inmsg_chunks++; sws->inmsg_total_size += sws->inmsg_current_chunk_len; sws->inmsg_current_chunk_buf = nn_msg_chunk_new (sws->inmsg_current_chunk_len, &sws->inmsg_array); } nn_usock_recv (sws->usock, sws->inmsg_current_chunk_buf, sws->inmsg_current_chunk_len, NULL); return; } else { /* Continue receiving the rest of the header frame. */ sws->instate = NN_SWS_INSTATE_RECV_HDREXT; nn_usock_recv (sws->usock, sws->inhdr + NN_SWS_FRAME_SIZE_INITIAL, sws->ext_hdr_len, NULL); return; } case NN_SWS_INSTATE_RECV_HDREXT: nn_assert (sws->ext_hdr_len > 0); if (sws->payload_ctl <= NN_SWS_PAYLOAD_MAX_LENGTH) { sws->inmsg_current_chunk_len = sws->payload_ctl; if (sws->masked) { sws->mask = sws->inhdr + NN_SWS_FRAME_SIZE_INITIAL; } else { sws->mask = NULL; } } else if (sws->payload_ctl == NN_SWS_PAYLOAD_FRAME_16) { sws->inmsg_current_chunk_len = nn_gets (sws->inhdr + NN_SWS_FRAME_SIZE_INITIAL); if (sws->masked) { sws->mask = sws->inhdr + NN_SWS_FRAME_SIZE_INITIAL + NN_SWS_FRAME_SIZE_PAYLOAD_16; } else { sws->mask = NULL; } } else if (sws->payload_ctl == NN_SWS_PAYLOAD_FRAME_63) { sws->inmsg_current_chunk_len = (size_t) nn_getll (sws->inhdr + NN_SWS_FRAME_SIZE_INITIAL); if (sws->masked) { sws->mask = sws->inhdr + NN_SWS_FRAME_SIZE_INITIAL + NN_SWS_FRAME_SIZE_PAYLOAD_63; } else { sws->mask = NULL; } } else { /* Client sent invalid data; as per RFC 6455, server closes the connection immediately. */ nn_sws_fail_conn (sws, NN_SWS_CLOSE_ERR_PROTO, "Invalid payload length."); return; } /* Handle zero-length message bodies. */ if (sws->inmsg_current_chunk_len == 0) { if (sws->is_final_frame) { if (sws->opcode == NN_WS_OPCODE_CLOSE) { nn_pipebase_stop (&sws->pipebase); sws->state = NN_SWS_STATE_CLOSING_CONNECTION; } else { sws->instate = (sws->is_control_frame ? NN_SWS_INSTATE_RECVD_CONTROL : NN_SWS_INSTATE_RECVD_CHUNKED); nn_pipebase_received (&sws->pipebase); } } else { nn_sws_recv_hdr (sws); } return; } nn_assert (sws->inmsg_current_chunk_len > 0); /* Use scatter/gather array for application messages, and a fixed-width buffer for control messages. This is convenient since control messages can be interspersed between chunked application msgs. */ if (sws->is_control_frame) { sws->inmsg_current_chunk_buf = sws->inmsg_control; } else { sws->inmsg_chunks++; sws->inmsg_total_size += sws->inmsg_current_chunk_len; sws->inmsg_current_chunk_buf = nn_msg_chunk_new (sws->inmsg_current_chunk_len, &sws->inmsg_array); } sws->instate = NN_SWS_INSTATE_RECV_PAYLOAD; nn_usock_recv (sws->usock, sws->inmsg_current_chunk_buf, sws->inmsg_current_chunk_len, NULL); return; case NN_SWS_INSTATE_RECV_PAYLOAD: /* Unmask if necessary. */ if (sws->masked) { nn_sws_mask_payload (sws->inmsg_current_chunk_buf, sws->inmsg_current_chunk_len, sws->mask, NN_SWS_FRAME_SIZE_MASK, NULL); } switch (sws->opcode) { case NN_WS_OPCODE_TEXT: nn_sws_validate_utf8_chunk (sws); return; case NN_WS_OPCODE_BINARY: if (sws->is_final_frame) { sws->instate = NN_SWS_INSTATE_RECVD_CHUNKED; nn_pipebase_received (&sws->pipebase); } else { nn_sws_recv_hdr (sws); } return; case NN_WS_OPCODE_FRAGMENT: /* Must check original opcode to see if this fragment needs UTF-8 validation. */ if ((sws->inmsg_hdr & NN_SWS_FRAME_BITMASK_OPCODE) == NN_WS_OPCODE_TEXT) { nn_sws_validate_utf8_chunk (sws); } else if (sws->is_final_frame) { sws->instate = NN_SWS_INSTATE_RECVD_CHUNKED; nn_pipebase_received (&sws->pipebase); } else { nn_sws_recv_hdr (sws); } return; case NN_WS_OPCODE_PING: sws->instate = NN_SWS_INSTATE_RECVD_CONTROL; nn_pipebase_received (&sws->pipebase); return; case NN_WS_OPCODE_PONG: sws->instate = NN_SWS_INSTATE_RECVD_CONTROL; nn_pipebase_received (&sws->pipebase); return; case NN_WS_OPCODE_CLOSE: /* If the payload is not even long enough for the required 2-octet Close Code, the connection should have been failed upstream. */ nn_assert (sws->inmsg_current_chunk_len >= NN_SWS_CLOSE_CODE_LEN); nn_pipebase_stop (&sws->pipebase); sws->state = NN_SWS_STATE_CLOSING_CONNECTION; return; default: /* This should have been prevented upstream. */ nn_assert (0); return; } default: nn_fsm_error ("Unexpected socket instate", sws->state, src, type); } case NN_USOCK_SHUTDOWN: nn_pipebase_stop (&sws->pipebase); sws->state = NN_SWS_STATE_BROKEN_CONNECTION; return; case NN_USOCK_ERROR: nn_pipebase_stop (&sws->pipebase); sws->state = NN_SWS_STATE_DONE; nn_fsm_raise (&sws->fsm, &sws->done, NN_SWS_RETURN_ERROR); return; default: nn_fsm_bad_action (sws->state, src, type); } break; default: nn_fsm_bad_source (sws->state, src, type); } /******************************************************************************/ /* CLOSING_CONNECTION state. */ /* Wait for acknowledgement closing handshake was successfully sent. */ /******************************************************************************/ case NN_SWS_STATE_CLOSING_CONNECTION: switch (src) { case NN_SWS_SRC_USOCK: switch (type) { case NN_USOCK_SENT: /* Wait for acknowledgement closing handshake was sent to peer. */ nn_assert (sws->outstate == NN_SWS_OUTSTATE_SENDING); sws->outstate = NN_SWS_OUTSTATE_IDLE; sws->state = NN_SWS_STATE_DONE; nn_fsm_raise (&sws->fsm, &sws->done, NN_SWS_RETURN_CLOSE_HANDSHAKE); return; case NN_USOCK_SHUTDOWN: return; case NN_USOCK_ERROR: sws->state = NN_SWS_STATE_DONE; nn_fsm_raise (&sws->fsm, &sws->done, NN_SWS_RETURN_ERROR); return; default: nn_fsm_bad_action (sws->state, src, type); } default: nn_fsm_bad_source (sws->state, src, type); } /******************************************************************************/ /* SHUTTING_DOWN state. */ /* The underlying connection is closed. We are just waiting that underlying */ /* usock being closed */ /******************************************************************************/ case NN_SWS_STATE_BROKEN_CONNECTION: switch (src) { case NN_SWS_SRC_USOCK: switch (type) { case NN_USOCK_ERROR: sws->state = NN_SWS_STATE_DONE; nn_fsm_raise (&sws->fsm, &sws->done, NN_SWS_RETURN_ERROR); return; default: nn_fsm_bad_action (sws->state, src, type); } default: nn_fsm_bad_source (sws->state, src, type); } /******************************************************************************/ /* DONE state. */ /* The underlying connection is closed. There's nothing that can be done in */ /* this state except stopping the object. */ /******************************************************************************/ case NN_SWS_STATE_DONE: nn_fsm_bad_source (sws->state, src, type); /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (sws->state, src, type); } } nanomsg-0.8-beta/src/transports/ws/ws.h0000664000175000017500000000247312623652600021111 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 250bpm s.r.o. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. 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. */ #ifndef NN_WS_INCLUDED #define NN_WS_INCLUDED #include "../../transport.h" extern struct nn_transport *nn_ws; #endif nanomsg-0.8-beta/src/transports/ws/ws.c0000664000175000017500000001062612623652600021103 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 250bpm s.r.o. All rights reserved. Copyright (c) 2013 GoPivotal, Inc. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. All rights reserved. Copyright 2015 Garrett D'Amore 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 "ws.h" #include "bws.h" #include "cws.h" #include "sws.h" #include "../../ws.h" #include "../utils/port.h" #include "../utils/iface.h" #include "../../utils/err.h" #include "../../utils/alloc.h" #include "../../utils/fast.h" #include "../../utils/list.h" #include "../../utils/cont.h" #include #if defined NN_HAVE_WINDOWS #include "../../utils/win.h" #else #include #endif /* WebSocket-specific socket options. */ struct nn_ws_optset { struct nn_optset base; int msg_type; }; static void nn_ws_optset_destroy (struct nn_optset *self); static int nn_ws_optset_setopt (struct nn_optset *self, int option, const void *optval, size_t optvallen); static int nn_ws_optset_getopt (struct nn_optset *self, int option, void *optval, size_t *optvallen); static const struct nn_optset_vfptr nn_ws_optset_vfptr = { nn_ws_optset_destroy, nn_ws_optset_setopt, nn_ws_optset_getopt }; /* nn_transport interface. */ static int nn_ws_bind (void *hint, struct nn_epbase **epbase); static int nn_ws_connect (void *hint, struct nn_epbase **epbase); static struct nn_optset *nn_ws_optset (void); static struct nn_transport nn_ws_vfptr = { "ws", NN_WS, NULL, NULL, nn_ws_bind, nn_ws_connect, nn_ws_optset, NN_LIST_ITEM_INITIALIZER }; struct nn_transport *nn_ws = &nn_ws_vfptr; static int nn_ws_bind (void *hint, struct nn_epbase **epbase) { return nn_bws_create (hint, epbase); } static int nn_ws_connect (void *hint, struct nn_epbase **epbase) { return nn_cws_create (hint, epbase); } static struct nn_optset *nn_ws_optset () { struct nn_ws_optset *optset; optset = nn_alloc (sizeof (struct nn_ws_optset), "optset (ws)"); alloc_assert (optset); optset->base.vfptr = &nn_ws_optset_vfptr; /* Default values for WebSocket options. */ optset->msg_type = NN_WS_MSG_TYPE_BINARY; return &optset->base; } static void nn_ws_optset_destroy (struct nn_optset *self) { struct nn_ws_optset *optset; optset = nn_cont (self, struct nn_ws_optset, base); nn_free (optset); } static int nn_ws_optset_setopt (struct nn_optset *self, int option, const void *optval, size_t optvallen) { struct nn_ws_optset *optset; int val; optset = nn_cont (self, struct nn_ws_optset, base); if (optvallen != sizeof (int)) { return -EINVAL; } val = *(int *)optval; switch (option) { case NN_WS_MSG_TYPE: switch (val) { case NN_WS_MSG_TYPE_TEXT: case NN_WS_MSG_TYPE_BINARY: optset->msg_type = val; return 0; default: return -EINVAL; } default: return -ENOPROTOOPT; } } static int nn_ws_optset_getopt (struct nn_optset *self, int option, void *optval, size_t *optvallen) { struct nn_ws_optset *optset; optset = nn_cont (self, struct nn_ws_optset, base); switch (option) { case NN_WS_MSG_TYPE: memcpy (optval, &optset->msg_type, *optvallen < sizeof (int) ? *optvallen : sizeof (int)); *optvallen = sizeof (int); return 0; default: return -ENOPROTOOPT; } } nanomsg-0.8-beta/src/transports/ws/ws_handshake.h0000664000175000017500000001252312623652600023114 0ustar00travistravis00000000000000/* Copyright (c) 2013 250bpm s.r.o. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. All rights reserved. Copyright 2015 Garrett D'Amore 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. */ #ifndef NN_WS_HANDSHAKE_INCLUDED #define NN_WS_HANDSHAKE_INCLUDED #include "../../transport.h" #include "../../aio/fsm.h" #include "../../aio/usock.h" #include "../../aio/timer.h" #include "../../utils/int.h" /* This state machine exchanges a handshake with a WebSocket client. */ /* Return codes of this state machine. */ #define NN_WS_HANDSHAKE_OK 1 #define NN_WS_HANDSHAKE_ERROR 2 #define NN_WS_HANDSHAKE_STOPPED 3 /* WebSocket endpoint modes that determine framing of Tx/Rx and Opening Handshake HTTP headers. */ #define NN_WS_CLIENT 1 #define NN_WS_SERVER 2 /* A ws:// buffer for nanomsg is intentionally smaller than recommendation of RFC 7230 3.1.1 since it neither requires nor accepts arbitrarily large headers. */ #define NN_WS_HANDSHAKE_MAX_SIZE 4096 /* WebSocket protocol tokens as per RFC 6455. */ #define NN_WS_HANDSHAKE_MAGIC_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" #define NN_WS_HANDSHAKE_CRLF "\r\n" #define NN_WS_HANDSHAKE_TERMSEQ "\r\n\r\n" #define NN_WS_HANDSHAKE_TERMSEQ_LEN strlen (NN_WS_HANDSHAKE_TERMSEQ) /* Expected Accept Key length based on RFC 6455 4.2.2.5.4. */ #define NN_WS_HANDSHAKE_ACCEPT_KEY_LEN 28 struct nn_ws_handshake { /* The state machine. */ struct nn_fsm fsm; int state; /* Controls HTTP headers and behavior based on whether this peer is acting as a Client or a Server. */ int mode; /* Used to timeout opening handshake. */ struct nn_timer timer; int timeout; /* The underlying socket. */ struct nn_usock *usock; /* The original owner of the underlying socket. */ struct nn_fsm_owner usock_owner; /* Handle to the pipe. */ struct nn_pipebase *pipebase; /* Requested resource when acting as client. */ const char* resource; /* Remote Host in header request when acting as client. */ const char* remote_host; /* Opening handshake verbatim from client as per RFC 6455 1.3. */ char opening_hs [NN_WS_HANDSHAKE_MAX_SIZE]; /* Monitor/control the opening recv poll. */ int retries; size_t recv_pos; size_t recv_len; /* Expected handshake fields from client as per RFC 6455 4.1, where these pointers reference the opening_hs. */ const char *host; size_t host_len; const char *origin; size_t origin_len; const char *key; size_t key_len; const char *upgrade; size_t upgrade_len; const char *conn; size_t conn_len; const char *version; size_t version_len; /* Expected handshake fields from client required by nanomsg. */ const char *protocol; size_t protocol_len; /* Expected handshake fields from server as per RFC 6455 4.2.2. */ const char *server; size_t server_len; const char *accept_key; size_t accept_key_len; char expected_accept_key [NN_WS_HANDSHAKE_ACCEPT_KEY_LEN + 1]; const char *status_code; size_t status_code_len; const char *reason_phrase; size_t reason_phrase_len; /* Unused, optional handshake fields. */ const char *uri; size_t uri_len; const char *extensions; size_t extensions_len; /* Identifies the response to be sent to client's opening handshake. */ int response_code; /* Response to send back to client. */ char response [512]; /* Event fired when the state machine ends. */ struct nn_fsm_event done; }; /* Structure that maps scalability protocol to corresponding WebSocket header values. */ struct nn_ws_sp_map { /* Scalability Protocol ID for server... */ int server; /* ... and corresponding client Protocol ID */ int client; /* ... and corresponding WebSocket header field value. */ const char* ws_sp; }; void nn_ws_handshake_init (struct nn_ws_handshake *self, int src, struct nn_fsm *owner); void nn_ws_handshake_term (struct nn_ws_handshake *self); int nn_ws_handshake_isidle (struct nn_ws_handshake *self); void nn_ws_handshake_start (struct nn_ws_handshake *self, struct nn_usock *usock, struct nn_pipebase *pipebase, int mode, const char *resource, const char *host); void nn_ws_handshake_stop (struct nn_ws_handshake *self); #endif nanomsg-0.8-beta/src/transports/ws/ws_handshake.c0000664000175000017500000014633212623652600023115 0ustar00travistravis00000000000000/* Copyright (c) 2013 250bpm s.r.o. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. All rights reserved. Copyright 2015 Garrett D'Amore 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 "ws_handshake.h" #include "sha1.h" #include "../../aio/timer.h" #include "../../core/sock.h" #include "../utils/base64.h" #include "../../utils/alloc.h" #include "../../utils/err.h" #include "../../utils/cont.h" #include "../../utils/fast.h" #include "../../utils/wire.h" #include "../../utils/attr.h" #include "../../utils/random.h" #include #include #include /*****************************************************************************/ /*** BEGIN undesirable dependency *******************************************/ /*****************************************************************************/ /* TODO: A transport should be SP agnostic; alas, these includes are */ /* required for the map. Ideally, this map would live in another */ /* abstraction layer; perhaps a "registry" of Scalability Protocols? */ /*****************************************************************************/ #include "../../pair.h" #include "../../reqrep.h" #include "../../pubsub.h" #include "../../survey.h" #include "../../pipeline.h" #include "../../bus.h" static const struct nn_ws_sp_map NN_WS_HANDSHAKE_SP_MAP[] = { { NN_PAIR, NN_PAIR, "pair.sp.nanomsg.org" }, { NN_REQ, NN_REP, "req.sp.nanomsg.org" }, { NN_REP, NN_REQ, "rep.sp.nanomsg.org" }, { NN_PUB, NN_SUB, "pub.sp.nanomsg.org" }, { NN_SUB, NN_PUB, "sub.sp.nanomsg.org" }, { NN_SURVEYOR, NN_RESPONDENT, "surveyor.sp.nanomsg.org" }, { NN_RESPONDENT, NN_SURVEYOR, "respondent.sp.nanomsg.org" }, { NN_PUSH, NN_PULL, "push.sp.nanomsg.org" }, { NN_PULL, NN_PUSH, "pull.sp.nanomsg.org" }, { NN_BUS, NN_BUS, "bus.sp.nanomsg.org" } }; const size_t NN_WS_HANDSHAKE_SP_MAP_LEN = sizeof (NN_WS_HANDSHAKE_SP_MAP) / sizeof (NN_WS_HANDSHAKE_SP_MAP [0]); /*****************************************************************************/ /*** END undesirable dependency *********************************************/ /*****************************************************************************/ /* State machine finite states. */ #define NN_WS_HANDSHAKE_STATE_IDLE 1 #define NN_WS_HANDSHAKE_STATE_SERVER_RECV 2 #define NN_WS_HANDSHAKE_STATE_SERVER_REPLY 3 #define NN_WS_HANDSHAKE_STATE_CLIENT_SEND 4 #define NN_WS_HANDSHAKE_STATE_CLIENT_RECV 5 #define NN_WS_HANDSHAKE_STATE_HANDSHAKE_SENT 6 #define NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR 7 #define NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_DONE 8 #define NN_WS_HANDSHAKE_STATE_DONE 9 #define NN_WS_HANDSHAKE_STATE_STOPPING 10 /* Subordinate srcptr objects. */ #define NN_WS_HANDSHAKE_SRC_USOCK 1 #define NN_WS_HANDSHAKE_SRC_TIMER 2 /* Time allowed to complete handshake. */ #define NN_WS_HANDSHAKE_TIMEOUT 5000 /* Possible return codes internal to the parsing operations. */ #define NN_WS_HANDSHAKE_NOMATCH 0 #define NN_WS_HANDSHAKE_MATCH 1 /* Possible return codes from parsing opening handshake from peer. */ #define NN_WS_HANDSHAKE_VALID 0 #define NN_WS_HANDSHAKE_RECV_MORE 1 #define NN_WS_HANDSHAKE_INVALID -1 /* Possible handshake responses to send to client when acting as server. */ #define NN_WS_HANDSHAKE_RESPONSE_NULL -1 #define NN_WS_HANDSHAKE_RESPONSE_OK 0 #define NN_WS_HANDSHAKE_RESPONSE_TOO_BIG 1 #define NN_WS_HANDSHAKE_RESPONSE_UNUSED2 2 #define NN_WS_HANDSHAKE_RESPONSE_WSPROTO 3 #define NN_WS_HANDSHAKE_RESPONSE_WSVERSION 4 #define NN_WS_HANDSHAKE_RESPONSE_NNPROTO 5 #define NN_WS_HANDSHAKE_RESPONSE_NOTPEER 6 #define NN_WS_HANDSHAKE_RESPONSE_UNKNOWNTYPE 7 /* Private functions. */ static void nn_ws_handshake_handler (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_ws_handshake_shutdown (struct nn_fsm *self, int src, int type, void *srcptr); static void nn_ws_handshake_leave (struct nn_ws_handshake *self, int rc); /* WebSocket protocol support functions. */ static int nn_ws_handshake_parse_client_opening (struct nn_ws_handshake *self); static void nn_ws_handshake_server_reply (struct nn_ws_handshake *self); static void nn_ws_handshake_client_request (struct nn_ws_handshake *self); static int nn_ws_handshake_parse_server_response (struct nn_ws_handshake *self); static int nn_ws_handshake_hash_key (const char *key, size_t key_len, char *hashed, size_t hashed_len); /* String parsing support functions. */ /* Scans for reference token against subject string, optionally ignoring case sensitivity and/or leading spaces in subject. On match, advances the subject pointer to the next non-ignored character past match. Both strings must be NULL terminated to avoid undefined behavior. Returns NN_WS_HANDSHAKE_MATCH on match; else, NN_WS_HANDSHAKE_NOMATCH. */ static int nn_ws_match_token (const char* token, const char **subj, int case_insensitive, int ignore_leading_sp); /* Scans subject string for termination sequence, optionally ignoring leading and/or trailing spaces in subject. On match, advances the subject pointer to the next character past match. Both strings must be NULL terminated to avoid undefined behavior. If the match succeeds, values are stored into *addr and *len. */ static int nn_ws_match_value (const char* termseq, const char **subj, int ignore_leading_sp, int ignore_trailing_sp, const char **addr, size_t* const len); /* Compares subject octet stream to expected value, optionally ignoring case sensitivity. Returns non-zero on success, zero on failure. */ static int nn_ws_validate_value (const char* expected, const char *subj, size_t subj_len, int case_insensitive); void nn_ws_handshake_init (struct nn_ws_handshake *self, int src, struct nn_fsm *owner) { nn_fsm_init (&self->fsm, nn_ws_handshake_handler, nn_ws_handshake_shutdown, src, self, owner); self->state = NN_WS_HANDSHAKE_STATE_IDLE; nn_timer_init (&self->timer, NN_WS_HANDSHAKE_SRC_TIMER, &self->fsm); nn_fsm_event_init (&self->done); self->timeout = NN_WS_HANDSHAKE_TIMEOUT; self->usock = NULL; self->usock_owner.src = -1; self->usock_owner.fsm = NULL; self->pipebase = NULL; } void nn_ws_handshake_term (struct nn_ws_handshake *self) { nn_assert_state (self, NN_WS_HANDSHAKE_STATE_IDLE); nn_fsm_event_term (&self->done); nn_timer_term (&self->timer); nn_fsm_term (&self->fsm); } int nn_ws_handshake_isidle (struct nn_ws_handshake *self) { return nn_fsm_isidle (&self->fsm); } void nn_ws_handshake_start (struct nn_ws_handshake *self, struct nn_usock *usock, struct nn_pipebase *pipebase, int mode, const char *resource, const char *host) { /* It's expected this resource has been allocated during intial connect. */ if (mode == NN_WS_CLIENT) nn_assert (strlen (resource) >= 1); /* Take ownership of the underlying socket. */ nn_assert (self->usock == NULL && self->usock_owner.fsm == NULL); self->usock_owner.src = NN_WS_HANDSHAKE_SRC_USOCK; self->usock_owner.fsm = &self->fsm; nn_usock_swap_owner (usock, &self->usock_owner); self->usock = usock; self->pipebase = pipebase; self->mode = mode; self->resource = resource; self->remote_host = host; memset (self->opening_hs, 0, sizeof (self->opening_hs)); memset (self->response, 0, sizeof (self->response)); self->recv_pos = 0; self->retries = 0; /* Calculate the absolute minimum length possible for a valid opening handshake. This is an optimization since we must poll for the remainder of the opening handshake in small byte chunks. */ switch (self->mode) { case NN_WS_SERVER: self->recv_len = strlen ( "GET x HTTP/1.1\r\n" "Upgrade: websocket\r\n" "Connection: Upgrade\r\n" "Host: x\r\n" "Origin: x\r\n" "Sec-WebSocket-Key: xxxxxxxxxxxxxxxxxxxxxxxx\r\n" "Sec-WebSocket-Version: xx\r\n\r\n"); break; case NN_WS_CLIENT: /* Shortest conceiveable response from server is a terse status. */ self->recv_len = strlen ("HTTP/1.1 xxx\r\n\r\n"); break; default: /* Developer error; unexpected mode. */ nn_assert (0); break; } /* Launch the state machine. */ nn_fsm_start (&self->fsm); } void nn_ws_handshake_stop (struct nn_ws_handshake *self) { nn_fsm_stop (&self->fsm); } static void nn_ws_handshake_shutdown (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_ws_handshake *handshaker; handshaker = nn_cont (self, struct nn_ws_handshake, fsm); if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) { nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING; } if (nn_slow (handshaker->state == NN_WS_HANDSHAKE_STATE_STOPPING)) { if (!nn_timer_isidle (&handshaker->timer)) return; handshaker->state = NN_WS_HANDSHAKE_STATE_IDLE; nn_fsm_stopped (&handshaker->fsm, NN_WS_HANDSHAKE_STOPPED); return; } nn_fsm_bad_state (handshaker->state, src, type); } static int nn_ws_match_token (const char* token, const char **subj, int case_insensitive, int ignore_leading_sp) { const char *pos; nn_assert (token && *subj); pos = *subj; if (ignore_leading_sp) { while (*pos == '\x20' && *pos) { pos++; } } if (case_insensitive) { while (*token && *pos) { if (tolower (*token) != tolower (*pos)) return NN_WS_HANDSHAKE_NOMATCH; token++; pos++; } } else { while (*token && *pos) { if (*token != *pos) return NN_WS_HANDSHAKE_NOMATCH; token++; pos++; } } /* Encountered end of subject before matching completed. */ if (!*pos && *token) return NN_WS_HANDSHAKE_NOMATCH; /* Entire token has been matched. */ nn_assert (!*token); /* On success, advance subject position. */ *subj = pos; return NN_WS_HANDSHAKE_MATCH; } static int nn_ws_match_value (const char* termseq, const char **subj, int ignore_leading_sp, int ignore_trailing_sp, const char **addr, size_t* const len) { const char *start; const char *end; nn_assert (termseq && *subj); start = *subj; if (addr) *addr = NULL; if (len) *len = 0; /* Find first occurence of termination sequence. */ end = strstr (start, termseq); /* Was a termination sequence found? */ if (end) { *subj = end + strlen (termseq); } else { return NN_WS_HANDSHAKE_NOMATCH; } if (ignore_leading_sp) { while (*start == '\x20' && start < end) { start++; } } if (addr) *addr = start; /* In this special case, the value was "found", but is just empty or ignored space. */ if (start == end) return NN_WS_HANDSHAKE_MATCH; if (ignore_trailing_sp) { while (*(end - 1) == '\x20' && start < end) { end--; } } if (len) *len = end - start; return NN_WS_HANDSHAKE_MATCH; } static int nn_ws_validate_value (const char* expected, const char *subj, size_t subj_len, int case_insensitive) { if (strlen (expected) != subj_len) return NN_WS_HANDSHAKE_NOMATCH; if (case_insensitive) { while (*expected && *subj) { if (tolower (*expected) != tolower (*subj)) return NN_WS_HANDSHAKE_NOMATCH; expected++; subj++; } } else { while (*expected && *subj) { if (*expected != *subj) return NN_WS_HANDSHAKE_NOMATCH; expected++; subj++; } } return NN_WS_HANDSHAKE_MATCH; } static void nn_ws_handshake_handler (struct nn_fsm *self, int src, int type, NN_UNUSED void *srcptr) { struct nn_ws_handshake *handshaker; unsigned i; handshaker = nn_cont (self, struct nn_ws_handshake, fsm); switch (handshaker->state) { /******************************************************************************/ /* IDLE state. */ /******************************************************************************/ case NN_WS_HANDSHAKE_STATE_IDLE: switch (src) { case NN_FSM_ACTION: switch (type) { case NN_FSM_START: nn_assert (handshaker->recv_pos == 0); nn_assert (handshaker->recv_len >= NN_WS_HANDSHAKE_TERMSEQ_LEN); nn_timer_start (&handshaker->timer, handshaker->timeout); switch (handshaker->mode) { case NN_WS_CLIENT: /* Send opening handshake to server. */ nn_assert (handshaker->recv_len <= sizeof (handshaker->response)); handshaker->state = NN_WS_HANDSHAKE_STATE_CLIENT_SEND; nn_ws_handshake_client_request (handshaker); return; case NN_WS_SERVER: /* Begin receiving opening handshake from client. */ nn_assert (handshaker->recv_len <= sizeof (handshaker->opening_hs)); handshaker->state = NN_WS_HANDSHAKE_STATE_SERVER_RECV; nn_usock_recv (handshaker->usock, handshaker->opening_hs, handshaker->recv_len, NULL); return; default: /* Unexpected mode. */ nn_assert (0); return; } default: nn_fsm_bad_action (handshaker->state, src, type); } default: nn_fsm_bad_source (handshaker->state, src, type); } /******************************************************************************/ /* SERVER_RECV state. */ /******************************************************************************/ case NN_WS_HANDSHAKE_STATE_SERVER_RECV: switch (src) { case NN_WS_HANDSHAKE_SRC_USOCK: switch (type) { case NN_USOCK_RECEIVED: /* Parse bytes received thus far. */ switch (nn_ws_handshake_parse_client_opening (handshaker)) { case NN_WS_HANDSHAKE_INVALID: /* Opening handshake parsed successfully but does not contain valid values. Respond failure to client. */ handshaker->state = NN_WS_HANDSHAKE_STATE_SERVER_REPLY; nn_ws_handshake_server_reply (handshaker); return; case NN_WS_HANDSHAKE_VALID: /* Opening handshake parsed successfully, and is valid. Respond success to client. */ handshaker->state = NN_WS_HANDSHAKE_STATE_SERVER_REPLY; nn_ws_handshake_server_reply (handshaker); return; case NN_WS_HANDSHAKE_RECV_MORE: /* Not enough bytes have been received to determine validity; remain in the receive state, and retrieve more bytes from client. */ handshaker->recv_pos += handshaker->recv_len; /* Validate the previous recv operation. */ nn_assert (handshaker->recv_pos < sizeof (handshaker->opening_hs)); /* Ensure we can back-track at least the length of the termination sequence to determine how many bytes to receive on the next retry. This is an assertion, not a conditional, since under no condition is it necessary to initially receive so few bytes. */ nn_assert (handshaker->recv_pos >= (int) NN_WS_HANDSHAKE_TERMSEQ_LEN); /* We only compare if we have at least one byte to compare against. When i drops to zero, it means we don't have any bytes to match against, and it is automatically true. */ for (i = NN_WS_HANDSHAKE_TERMSEQ_LEN; i > 0; i--) { if (memcmp (NN_WS_HANDSHAKE_TERMSEQ, handshaker->opening_hs + handshaker->recv_pos - i, i) == 0) { break; } } nn_assert (i < NN_WS_HANDSHAKE_TERMSEQ_LEN); handshaker->recv_len = NN_WS_HANDSHAKE_TERMSEQ_LEN - i; /* In the unlikely case the client would overflow what we assumed was a sufficiently-large buffer to receive the handshake, we fail the client. */ if (handshaker->recv_len + handshaker->recv_pos > sizeof (handshaker->opening_hs)) { handshaker->response_code = NN_WS_HANDSHAKE_RESPONSE_TOO_BIG; handshaker->state = NN_WS_HANDSHAKE_STATE_SERVER_REPLY; nn_ws_handshake_server_reply (handshaker); } else { handshaker->retries++; nn_usock_recv (handshaker->usock, handshaker->opening_hs + handshaker->recv_pos, handshaker->recv_len, NULL); } return; default: nn_fsm_error ("Unexpected handshake result", handshaker->state, src, type); } return; case NN_USOCK_SHUTDOWN: /* Ignore it and wait for ERROR event. */ return; case NN_USOCK_ERROR: nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR; return; default: nn_fsm_bad_action (handshaker->state, src, type); } case NN_WS_HANDSHAKE_SRC_TIMER: switch (type) { case NN_TIMER_TIMEOUT: nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR; return; default: nn_fsm_bad_action (handshaker->state, src, type); } default: nn_fsm_bad_source (handshaker->state, src, type); } /******************************************************************************/ /* SERVER_REPLY state. */ /******************************************************************************/ case NN_WS_HANDSHAKE_STATE_SERVER_REPLY: switch (src) { case NN_WS_HANDSHAKE_SRC_USOCK: switch (type) { case NN_USOCK_SENT: /* As per RFC 6455 4.2.2, the handshake is now complete and the connection is immediately ready for send/recv. */ nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_DONE; case NN_USOCK_SHUTDOWN: /* Ignore it and wait for ERROR event. */ return; case NN_USOCK_ERROR: nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR; return; default: nn_fsm_bad_action (handshaker->state, src, type); } case NN_WS_HANDSHAKE_SRC_TIMER: switch (type) { case NN_TIMER_TIMEOUT: nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR; return; default: nn_fsm_bad_action (handshaker->state, src, type); } default: nn_fsm_bad_source (handshaker->state, src, type); } /******************************************************************************/ /* CLIENT_SEND state. */ /******************************************************************************/ case NN_WS_HANDSHAKE_STATE_CLIENT_SEND: switch (src) { case NN_WS_HANDSHAKE_SRC_USOCK: switch (type) { case NN_USOCK_SENT: handshaker->state = NN_WS_HANDSHAKE_STATE_CLIENT_RECV; nn_usock_recv (handshaker->usock, handshaker->response, handshaker->recv_len, NULL); return; case NN_USOCK_SHUTDOWN: /* Ignore it and wait for ERROR event. */ return; case NN_USOCK_ERROR: nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR; return; default: nn_fsm_bad_action (handshaker->state, src, type); } case NN_WS_HANDSHAKE_SRC_TIMER: switch (type) { case NN_TIMER_TIMEOUT: nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR; return; default: nn_fsm_bad_action (handshaker->state, src, type); } default: nn_fsm_bad_source (handshaker->state, src, type); } /******************************************************************************/ /* CLIENT_RECV state. */ /******************************************************************************/ case NN_WS_HANDSHAKE_STATE_CLIENT_RECV: switch (src) { case NN_WS_HANDSHAKE_SRC_USOCK: switch (type) { case NN_USOCK_RECEIVED: /* Parse bytes received thus far. */ switch (nn_ws_handshake_parse_server_response (handshaker)) { case NN_WS_HANDSHAKE_INVALID: /* Opening handshake parsed successfully but does not contain valid values. Fail connection. */ nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR; return; case NN_WS_HANDSHAKE_VALID: /* As per RFC 6455 4.2.2, the handshake is now complete and the connection is immediately ready for send/recv. */ nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_DONE; return; case NN_WS_HANDSHAKE_RECV_MORE: /* Not enough bytes have been received to determine validity; remain in the receive state, and retrieve more bytes from client. */ handshaker->recv_pos += handshaker->recv_len; /* Validate the previous recv operation. */ nn_assert (handshaker->recv_pos < sizeof (handshaker->response)); /* Ensure we can back-track at least the length of the termination sequence to determine how many bytes to receive on the next retry. This is an assertion, not a conditional, since under no condition is it necessary to initially receive so few bytes. */ nn_assert (handshaker->recv_pos >= (int) NN_WS_HANDSHAKE_TERMSEQ_LEN); /* If i goes to 0, it no need to compare. */ for (i = NN_WS_HANDSHAKE_TERMSEQ_LEN; i > 0; i--) { if (memcmp (NN_WS_HANDSHAKE_TERMSEQ, handshaker->response + handshaker->recv_pos - i, i) == 0) { break; } } nn_assert (i < NN_WS_HANDSHAKE_TERMSEQ_LEN); handshaker->recv_len = NN_WS_HANDSHAKE_TERMSEQ_LEN - i; /* In the unlikely case the client would overflow what we assumed was a sufficiently-large buffer to receive the handshake, we fail the connection. */ if (handshaker->recv_len + handshaker->recv_pos > sizeof (handshaker->response)) { nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR; } else { handshaker->retries++; nn_usock_recv (handshaker->usock, handshaker->response + handshaker->recv_pos, handshaker->recv_len, NULL); } return; default: nn_fsm_error ("Unexpected handshake result", handshaker->state, src, type); } return; case NN_USOCK_SHUTDOWN: /* Ignore it and wait for ERROR event. */ return; case NN_USOCK_ERROR: nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR; return; default: nn_fsm_bad_action (handshaker->state, src, type); } case NN_WS_HANDSHAKE_SRC_TIMER: switch (type) { case NN_TIMER_TIMEOUT: nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR; return; default: nn_fsm_bad_action (handshaker->state, src, type); } default: nn_fsm_bad_source (handshaker->state, src, type); } /******************************************************************************/ /* HANDSHAKE_SENT state. */ /******************************************************************************/ case NN_WS_HANDSHAKE_STATE_HANDSHAKE_SENT: switch (src) { case NN_WS_HANDSHAKE_SRC_USOCK: switch (type) { case NN_USOCK_SENT: /* As per RFC 6455 4.2.2, the handshake is now complete and the connection is immediately ready for send/recv. */ nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_DONE; return; case NN_USOCK_SHUTDOWN: /* Ignore it and wait for ERROR event. */ return; case NN_USOCK_ERROR: nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR; return; default: nn_fsm_bad_action (handshaker->state, src, type); } case NN_WS_HANDSHAKE_SRC_TIMER: switch (type) { case NN_TIMER_TIMEOUT: nn_timer_stop (&handshaker->timer); handshaker->state = NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR; return; default: nn_fsm_bad_action (handshaker->state, src, type); } default: nn_fsm_bad_source (handshaker->state, src, type); } /******************************************************************************/ /* STOPPING_TIMER_ERROR state. */ /******************************************************************************/ case NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_ERROR: switch (src) { case NN_WS_HANDSHAKE_SRC_USOCK: /* Ignore. The only circumstance the client would send bytes is to notify the server it is closing the connection. Wait for the socket to eventually error. */ return; case NN_WS_HANDSHAKE_SRC_TIMER: switch (type) { case NN_TIMER_STOPPED: nn_ws_handshake_leave (handshaker, NN_WS_HANDSHAKE_ERROR); return; default: nn_fsm_bad_action (handshaker->state, src, type); } default: nn_fsm_bad_source (handshaker->state, src, type); } /******************************************************************************/ /* STOPPING_TIMER_DONE state. */ /******************************************************************************/ case NN_WS_HANDSHAKE_STATE_STOPPING_TIMER_DONE: switch (src) { case NN_WS_HANDSHAKE_SRC_USOCK: /* Ignore. The only circumstance the client would send bytes is to notify the server it is closing the connection. Wait for the socket to eventually error. */ return; case NN_WS_HANDSHAKE_SRC_TIMER: switch (type) { case NN_TIMER_STOPPED: nn_ws_handshake_leave (handshaker, NN_WS_HANDSHAKE_OK); return; default: nn_fsm_bad_action (handshaker->state, src, type); } default: nn_fsm_bad_source (handshaker->state, src, type); } /******************************************************************************/ /* DONE state. */ /* The header exchange was either done successfully of failed. There's */ /* nothing that can be done in this state except stopping the object. */ /******************************************************************************/ case NN_WS_HANDSHAKE_STATE_DONE: nn_fsm_bad_source (handshaker->state, src, type); /******************************************************************************/ /* Invalid state. */ /******************************************************************************/ default: nn_fsm_bad_state (handshaker->state, src, type); } } /******************************************************************************/ /* State machine actions. */ /******************************************************************************/ static void nn_ws_handshake_leave (struct nn_ws_handshake *self, int rc) { nn_usock_swap_owner (self->usock, &self->usock_owner); self->usock = NULL; self->usock_owner.src = -1; self->usock_owner.fsm = NULL; self->state = NN_WS_HANDSHAKE_STATE_DONE; nn_fsm_raise (&self->fsm, &self->done, rc); } static int nn_ws_handshake_parse_client_opening (struct nn_ws_handshake *self) { /* As per RFC 6455 section 1.7, this parser is not intended to be a general-purpose parser for arbitrary HTTP headers. As with the design philosophy of nanomsg, application-specific exchanges are better reserved for accepted connections, not as fields within these headers. */ int rc; const char *pos; unsigned i; /* Guarantee that a NULL terminator exists to enable treating this recv buffer like a string. */ nn_assert (memchr (self->opening_hs, '\0', sizeof (self->opening_hs))); /* Having found the NULL terminator, from this point forward string functions may be used. */ nn_assert (strlen (self->opening_hs) < sizeof (self->opening_hs)); pos = self->opening_hs; /* Is the opening handshake from the client fully received? */ if (!strstr (pos, NN_WS_HANDSHAKE_TERMSEQ)) return NN_WS_HANDSHAKE_RECV_MORE; self->host = NULL; self->origin = NULL; self->key = NULL; self->upgrade = NULL; self->conn = NULL; self->version = NULL; self->protocol = NULL; self->uri = NULL; self->host_len = 0; self->origin_len = 0; self->key_len = 0; self->upgrade_len = 0; self->conn_len = 0; self->version_len = 0; self->protocol_len = 0; self->uri_len = 0; /* This function, if generating a return value that triggers a response to the client, should replace this sentinel value with a proper response code. */ self->response_code = NN_WS_HANDSHAKE_RESPONSE_NULL; /* RFC 7230 3.1.1 Request Line: HTTP Method Note requirement of one space and case sensitivity. */ if (!nn_ws_match_token ("GET\x20", &pos, 0, 0)) return NN_WS_HANDSHAKE_RECV_MORE; /* RFC 7230 3.1.1 Request Line: Requested Resource. */ if (!nn_ws_match_value ("\x20", &pos, 0, 0, &self->uri, &self->uri_len)) return NN_WS_HANDSHAKE_RECV_MORE; /* RFC 7230 3.1.1 Request Line: HTTP version. Note case sensitivity. */ if (!nn_ws_match_token ("HTTP/1.1", &pos, 0, 0)) return NN_WS_HANDSHAKE_RECV_MORE; if (!nn_ws_match_token (NN_WS_HANDSHAKE_CRLF, &pos, 0, 0)) return NN_WS_HANDSHAKE_RECV_MORE; /* It's expected the current position is now at the first header field. Match them one by one. */ while (strlen (pos)) { if (nn_ws_match_token ("Host:", &pos, 1, 0)) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->host, &self->host_len); } else if (nn_ws_match_token ("Origin:", &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->origin, &self->origin_len); } else if (nn_ws_match_token ("Sec-WebSocket-Key:", &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->key, &self->key_len); } else if (nn_ws_match_token ("Upgrade:", &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->upgrade, &self->upgrade_len); } else if (nn_ws_match_token ("Connection:", &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->conn, &self->conn_len); } else if (nn_ws_match_token ("Sec-WebSocket-Version:", &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->version, &self->version_len); } else if (nn_ws_match_token ("Sec-WebSocket-Protocol:", &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->protocol, &self->protocol_len); } else if (nn_ws_match_token ("Sec-WebSocket-Extensions:", &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->extensions, &self->extensions_len); } else if (nn_ws_match_token (NN_WS_HANDSHAKE_CRLF, &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { /* Exit loop since all headers are parsed. */ break; } else { /* Skip unknown headers. */ rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, NULL, NULL); } if (rc != NN_WS_HANDSHAKE_MATCH) return NN_WS_HANDSHAKE_RECV_MORE; } /* Validate the opening handshake is now fully parsed. Additionally, as per RFC 6455 section 4.1, the client should not send additional data after the opening handshake, so this assertion validates upstream recv logic prevented this case. */ nn_assert (strlen (pos) == 0); /* TODO: protocol expectations below this point are hard-coded here as an initial design decision. Perhaps in the future these values should be settable via compile time (or run-time socket) options? */ /* These header fields are required as per RFC 6455 section 4.1. */ if (!self->host || !self->upgrade || !self->conn || !self->key || !self->version) { self->response_code = NN_WS_HANDSHAKE_RESPONSE_WSPROTO; return NN_WS_HANDSHAKE_INVALID; } /* RFC 6455 section 4.2.1.6 (version December 2011). */ if (nn_ws_validate_value ("13", self->version, self->version_len, 1) != NN_WS_HANDSHAKE_MATCH) { self->response_code = NN_WS_HANDSHAKE_RESPONSE_WSVERSION; return NN_WS_HANDSHAKE_INVALID; } /* RFC 6455 section 4.2.1.3 (version December 2011). */ if (nn_ws_validate_value ("websocket", self->upgrade, self->upgrade_len, 1) != NN_WS_HANDSHAKE_MATCH) { self->response_code = NN_WS_HANDSHAKE_RESPONSE_WSPROTO; return NN_WS_HANDSHAKE_INVALID; } /* RFC 6455 section 4.2.1.4 (version December 2011). */ if (nn_ws_validate_value ("Upgrade", self->conn, self->conn_len, 1) != NN_WS_HANDSHAKE_MATCH) { self->response_code = NN_WS_HANDSHAKE_RESPONSE_WSPROTO; return NN_WS_HANDSHAKE_INVALID; } /* At this point, client meets RFC 6455 compliance for opening handshake. Now it's time to check nanomsg-imposed required handshake values. */ if (self->protocol) { /* Ensure the client SP is a compatible socket type. */ for (i = 0; i < NN_WS_HANDSHAKE_SP_MAP_LEN; i++) { if (nn_ws_validate_value (NN_WS_HANDSHAKE_SP_MAP [i].ws_sp, self->protocol, self->protocol_len, 1)) { if (self->pipebase->sock->socktype->protocol == NN_WS_HANDSHAKE_SP_MAP [i].server) { self->response_code = NN_WS_HANDSHAKE_RESPONSE_OK; return NN_WS_HANDSHAKE_VALID; } else { self->response_code = NN_WS_HANDSHAKE_RESPONSE_NOTPEER; return NN_WS_HANDSHAKE_INVALID; } break; } } self->response_code = NN_WS_HANDSHAKE_RESPONSE_UNKNOWNTYPE; return NN_WS_HANDSHAKE_INVALID; } else { /* Be permissive and generous here, assuming that if a protocol is not explicitly declared, PAIR is presumed. This enables interoperability with non-nanomsg remote peers, nominally by making the local socket PAIR type. For any other local socket type, we expect connection to be rejected as incompatible if the header is not specified. */ if (nn_pipebase_ispeer (self->pipebase, NN_PAIR)) { self->response_code = NN_WS_HANDSHAKE_RESPONSE_OK; return NN_WS_HANDSHAKE_VALID; } else { self->response_code = NN_WS_HANDSHAKE_RESPONSE_NOTPEER; return NN_WS_HANDSHAKE_INVALID; } } } static int nn_ws_handshake_parse_server_response (struct nn_ws_handshake *self) { /* As per RFC 6455 section 1.7, this parser is not intended to be a general-purpose parser for arbitrary HTTP headers. As with the design philosophy of nanomsg, application-specific exchanges are better reserved for accepted connections, not as fields within these headers. */ int rc; const char *pos; /* Guarantee that a NULL terminator exists to enable treating this recv buffer like a string. The lack of such would indicate a failure upstream to catch a buffer overflow. */ nn_assert (memchr (self->response, '\0', sizeof (self->response))); /* Having found the NULL terminator, from this point forward string functions may be used. */ nn_assert (strlen (self->response) < sizeof (self->response)); pos = self->response; /* Is the response from the server fully received? */ if (!strstr (pos, NN_WS_HANDSHAKE_TERMSEQ)) return NN_WS_HANDSHAKE_RECV_MORE; self->status_code = NULL; self->reason_phrase = NULL; self->server = NULL; self->accept_key = NULL; self->upgrade = NULL; self->conn = NULL; self->version = NULL; self->protocol = NULL; self->status_code_len = 0; self->reason_phrase_len = 0; self->server_len = 0; self->accept_key_len = 0; self->upgrade_len = 0; self->conn_len = 0; self->version_len = 0; self->protocol_len = 0; /* RFC 7230 3.1.2 Status Line: HTTP Version. */ if (!nn_ws_match_token ("HTTP/1.1\x20", &pos, 0, 0)) return NN_WS_HANDSHAKE_RECV_MORE; /* RFC 7230 3.1.2 Status Line: Status Code. */ if (!nn_ws_match_value ("\x20", &pos, 0, 0, &self->status_code, &self->status_code_len)) return NN_WS_HANDSHAKE_RECV_MORE; /* RFC 7230 3.1.2 Status Line: Reason Phrase. */ if (!nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 0, 0, &self->reason_phrase, &self->reason_phrase_len)) return NN_WS_HANDSHAKE_RECV_MORE; /* It's expected the current position is now at the first header field. Match them one by one. */ while (strlen (pos)) { if (nn_ws_match_token ("Server:", &pos, 1, 0)) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->server, &self->server_len); } else if (nn_ws_match_token ("Sec-WebSocket-Accept:", &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->accept_key, &self->accept_key_len); } else if (nn_ws_match_token ("Upgrade:", &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->upgrade, &self->upgrade_len); } else if (nn_ws_match_token ("Connection:", &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->conn, &self->conn_len); } else if (nn_ws_match_token ("Sec-WebSocket-Version-Server:", &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->version, &self->version_len); } else if (nn_ws_match_token ("Sec-WebSocket-Protocol-Server:", &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->protocol, &self->protocol_len); } else if (nn_ws_match_token ("Sec-WebSocket-Extensions:", &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, &self->extensions, &self->extensions_len); } else if (nn_ws_match_token (NN_WS_HANDSHAKE_CRLF, &pos, 1, 0) == NN_WS_HANDSHAKE_MATCH) { /* Exit loop since all headers are parsed. */ break; } else { /* Skip unknown headers. */ rc = nn_ws_match_value (NN_WS_HANDSHAKE_CRLF, &pos, 1, 1, NULL, NULL); } if (rc != NN_WS_HANDSHAKE_MATCH) return NN_WS_HANDSHAKE_RECV_MORE; } /* Validate the opening handshake is now fully parsed. Additionally, as per RFC 6455 section 4.1, the client should not send additional data after the opening handshake, so this assertion validates upstream recv logic prevented this case. */ nn_assert (strlen (pos) == 0); /* TODO: protocol expectations below this point are hard-coded here as an initial design decision. Perhaps in the future these values should be settable via compile time (or run-time socket) options? */ /* These header fields are required as per RFC 6455 4.2.2. */ if (!self->status_code || !self->upgrade || !self->conn || !self->accept_key) return NN_WS_HANDSHAKE_INVALID; /* TODO: Currently, we only handle a successful connection upgrade. Anything else is treated as a failed connection. Consider handling other scenarios like 3xx redirects. */ if (nn_ws_validate_value ("101", self->status_code, self->status_code_len, 1) != NN_WS_HANDSHAKE_MATCH) return NN_WS_HANDSHAKE_INVALID; /* RFC 6455 section 4.2.2.5.2 (version December 2011). */ if (nn_ws_validate_value ("websocket", self->upgrade, self->upgrade_len, 1) != NN_WS_HANDSHAKE_MATCH) return NN_WS_HANDSHAKE_INVALID; /* RFC 6455 section 4.2.2.5.3 (version December 2011). */ if (nn_ws_validate_value ("Upgrade", self->conn, self->conn_len, 1) != NN_WS_HANDSHAKE_MATCH) return NN_WS_HANDSHAKE_INVALID; /* RFC 6455 section 4.2.2.5.4 (version December 2011). */ if (nn_ws_validate_value (self->expected_accept_key, self->accept_key, self->accept_key_len, 1) != NN_WS_HANDSHAKE_MATCH) return NN_WS_HANDSHAKE_INVALID; /* Server response meets RFC 6455 compliance for opening handshake. */ return NN_WS_HANDSHAKE_VALID; } static void nn_ws_handshake_client_request (struct nn_ws_handshake *self) { struct nn_iovec open_request; size_t encoded_key_len; int rc; unsigned i; /* Generate random 16-byte key as per RFC 6455 4.1 */ uint8_t rand_key [16]; /* Known length required to base64 encode above random key plus string NULL terminator. */ char encoded_key [24 + 1]; nn_random_generate (rand_key, sizeof (rand_key)); rc = nn_base64_encode (rand_key, sizeof (rand_key), encoded_key, sizeof (encoded_key)); encoded_key_len = strlen (encoded_key); nn_assert (encoded_key_len == sizeof (encoded_key) - 1); /* Pre-calculated expected Accept Key value as per RFC 6455 section 4.2.2.5.4 (version December 2011). */ rc = nn_ws_handshake_hash_key (encoded_key, encoded_key_len, self->expected_accept_key, sizeof (self->expected_accept_key)); nn_assert (rc == NN_WS_HANDSHAKE_ACCEPT_KEY_LEN); /* Lookup SP header value. */ for (i = 0; i < NN_WS_HANDSHAKE_SP_MAP_LEN; i++) { if (NN_WS_HANDSHAKE_SP_MAP [i].client == self->pipebase->sock->socktype->protocol) { break; } } /* Guarantee that the socket type was found in the map. */ nn_assert (i < NN_WS_HANDSHAKE_SP_MAP_LEN); sprintf (self->opening_hs, "GET %s HTTP/1.1\r\n" "Host: %s\r\n" "Upgrade: websocket\r\n" "Connection: Upgrade\r\n" "Sec-WebSocket-Key: %s\r\n" "Sec-WebSocket-Version: 13\r\n" "Sec-WebSocket-Protocol: %s\r\n\r\n", self->resource, self->remote_host, encoded_key, NN_WS_HANDSHAKE_SP_MAP[i].ws_sp); open_request.iov_len = strlen (self->opening_hs); open_request.iov_base = self->opening_hs; nn_usock_send (self->usock, &open_request, 1); } static void nn_ws_handshake_server_reply (struct nn_ws_handshake *self) { struct nn_iovec response; char *code; char *version; char *protocol; int rc; /* Allow room for NULL terminator. */ char accept_key [NN_WS_HANDSHAKE_ACCEPT_KEY_LEN + 1]; memset (self->response, 0, sizeof (self->response)); if (self->response_code == NN_WS_HANDSHAKE_RESPONSE_OK) { /* Upgrade connection as per RFC 6455 section 4.2.2. */ rc = nn_ws_handshake_hash_key (self->key, self->key_len, accept_key, sizeof (accept_key)); nn_assert (strlen (accept_key) == NN_WS_HANDSHAKE_ACCEPT_KEY_LEN); protocol = nn_alloc (self->protocol_len + 1, "WebSocket protocol"); alloc_assert (protocol); strncpy (protocol, self->protocol, self->protocol_len); protocol [self->protocol_len] = '\0'; sprintf (self->response, "HTTP/1.1 101 Switching Protocols\r\n" "Upgrade: websocket\r\n" "Connection: Upgrade\r\n" "Sec-WebSocket-Accept: %s\r\n" "Sec-WebSocket-Protocol: %s\r\n\r\n", accept_key, protocol); nn_free (protocol); } else { /* Fail the connection with a helpful hint. */ switch (self->response_code) { case NN_WS_HANDSHAKE_RESPONSE_TOO_BIG: code = "400 Opening Handshake Too Long"; break; case NN_WS_HANDSHAKE_RESPONSE_WSPROTO: code = "400 Cannot Have Body"; break; case NN_WS_HANDSHAKE_RESPONSE_WSVERSION: code = "400 Unsupported WebSocket Version"; break; case NN_WS_HANDSHAKE_RESPONSE_NNPROTO: code = "400 Missing nanomsg Required Headers"; break; case NN_WS_HANDSHAKE_RESPONSE_NOTPEER: code = "400 Incompatible Socket Type"; break; case NN_WS_HANDSHAKE_RESPONSE_UNKNOWNTYPE: code = "400 Unrecognized Socket Type"; break; default: /* Unexpected failure response. */ nn_assert (0); break; } version = nn_alloc (self->version_len + 1, "WebSocket version"); alloc_assert (version); strncpy (version, self->version, self->version_len); version [self->version_len] = '\0'; /* Fail connection as per RFC 6455 4.4. */ sprintf (self->response, "HTTP/1.1 %s\r\n" "Sec-WebSocket-Version: %s\r\n", code, version); nn_free (version); } response.iov_len = strlen (self->response); response.iov_base = &self->response; nn_usock_send (self->usock, &response, 1); return; } static int nn_ws_handshake_hash_key (const char *key, size_t key_len, char *hashed, size_t hashed_len) { int rc; unsigned i; struct nn_sha1 hash; nn_sha1_init (&hash); for (i = 0; i < key_len; i++) nn_sha1_hashbyte (&hash, key [i]); for (i = 0; i < strlen (NN_WS_HANDSHAKE_MAGIC_GUID); i++) nn_sha1_hashbyte (&hash, NN_WS_HANDSHAKE_MAGIC_GUID [i]); rc = nn_base64_encode (nn_sha1_result (&hash), sizeof (hash.state), hashed, hashed_len); return rc; } nanomsg-0.8-beta/src/transports/ws/sha1.h0000664000175000017500000000510312623652600021305 0ustar00travistravis00000000000000/* Copyright (c) 2014 Wirebird Labs LLC. 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. */ #ifndef NN_SHA1_INCLUDED #define NN_SHA1_INCLUDED #include "../../utils/int.h" /*****************************************************************************/ /* SHA-1 SECURITY NOTICE: */ /* The algorithm as designed below is not intended for general purpose use. */ /* As-designed, it is a single-purpose function for this WebSocket */ /* Opening Handshake. As per RFC 6455 10.8, SHA-1 usage "doesn't depend on */ /* any security properties of SHA-1, such as collision resistance or */ /* resistance to the second pre-image attack (as described in [RFC4270])". */ /* Caveat emptor for uses of this function elsewhere. */ /* */ /* Based on sha1.c (Public Domain) by Steve Reid, these functions calculate */ /* the SHA1 hash of arbitrary byte locations byte-by-byte. */ /*****************************************************************************/ #define SHA1_HASH_LEN 20 #define SHA1_BLOCK_LEN 64 struct nn_sha1 { uint32_t buffer [SHA1_BLOCK_LEN / sizeof (uint32_t)]; uint32_t state [SHA1_HASH_LEN / sizeof (uint32_t)]; uint32_t bytes_hashed; uint8_t buffer_offset; uint8_t is_little_endian; }; void nn_sha1_init (struct nn_sha1 *self); void nn_sha1_hashbyte (struct nn_sha1 *self, uint8_t data); uint8_t* nn_sha1_result (struct nn_sha1 *self); #endif nanomsg-0.8-beta/src/transports/ws/sha1.c0000664000175000017500000001072312623652600021304 0ustar00travistravis00000000000000/* Copyright (c) 2014 Wirebird Labs LLC. 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 "sha1.h" #define sha1_rol32(num,bits) ((num << bits) | (num >> (32 - bits))) void nn_sha1_init (struct nn_sha1 *self) { /* Detect endianness. */ union { uint32_t i; char c[4]; } test = { 0x00000001 }; self->is_little_endian = test.c[0]; /* Initial state of the hash. */ self->state [0] = 0x67452301; self->state [1] = 0xefcdab89; self->state [2] = 0x98badcfe; self->state [3] = 0x10325476; self->state [4] = 0xc3d2e1f0; self->bytes_hashed = 0; self->buffer_offset = 0; } static void nn_sha1_add (struct nn_sha1 *self, uint8_t data) { uint8_t i; uint32_t a, b, c, d, e, t; uint8_t * const buf = (uint8_t*) self->buffer; if (self->is_little_endian) buf [self->buffer_offset ^ 3] = data; else buf [self->buffer_offset] = data; self->buffer_offset++; if (self->buffer_offset == SHA1_BLOCK_LEN) { a = self->state [0]; b = self->state [1]; c = self->state [2]; d = self->state [3]; e = self->state [4]; for (i = 0; i < 80; i++) { if (i >= 16) { t = self->buffer [(i + 13) & 15] ^ self->buffer [(i + 8) & 15] ^ self->buffer [(i + 2) & 15] ^ self->buffer [i & 15]; self->buffer [i & 15] = sha1_rol32 (t, 1); } if (i < 20) t = (d ^ (b & (c ^ d))) + 0x5A827999; else if (i < 40) t = (b ^ c ^ d) + 0x6ED9EBA1; else if (i < 60) t = ((b & c) | (d & (b | c))) + 0x8F1BBCDC; else t = (b ^ c ^ d) + 0xCA62C1D6; t += sha1_rol32 (a, 5) + e + self->buffer [i & 15]; e = d; d = c; c = sha1_rol32 (b, 30); b = a; a = t; } self->state [0] += a; self->state [1] += b; self->state [2] += c; self->state [3] += d; self->state [4] += e; self->buffer_offset = 0; } } void nn_sha1_hashbyte (struct nn_sha1 *self, uint8_t data) { ++self->bytes_hashed; nn_sha1_add (self, data); } uint8_t* nn_sha1_result (struct nn_sha1 *self) { int i; /* Pad to complete the last block. */ nn_sha1_add (self, 0x80); while (self->buffer_offset != 56) nn_sha1_add (self, 0x00); /* Append length in the last 8 bytes. SHA-1 supports 64-bit hashes, so zero-pad the top bits. Shifting to multiply by 8 as SHA-1 supports bit- as well as byte-streams. */ nn_sha1_add (self, 0); nn_sha1_add (self, 0); nn_sha1_add (self, 0); nn_sha1_add (self, self->bytes_hashed >> 29); nn_sha1_add (self, self->bytes_hashed >> 21); nn_sha1_add (self, self->bytes_hashed >> 13); nn_sha1_add (self, self->bytes_hashed >> 5); nn_sha1_add (self, self->bytes_hashed << 3); /* Correct byte order for little-endian systems. */ if (self->is_little_endian) { for (i = 0; i < 5; i++) { self->state [i] = (((self->state [i]) << 24) & 0xFF000000) | (((self->state [i]) << 8) & 0x00FF0000) | (((self->state [i]) >> 8) & 0x0000FF00) | (((self->state [i]) >> 24) & 0x000000FF); } } /* 20-octet pointer to hash. */ return (uint8_t*) self->state; } nanomsg-0.8-beta/src/utils/0000775000175000017500000000000012623652617016601 5ustar00travistravis00000000000000nanomsg-0.8-beta/src/utils/alloc.h0000664000175000017500000000321012623652600020030 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef NN_ALLOC_INCLUDED #define NN_ALLOC_INCLUDED #include /* These functions allow for interception of memory allocation-related functionality. */ void nn_alloc_init (void); void nn_alloc_term (void); void *nn_realloc (void *ptr, size_t size); void nn_free (void *ptr); #if defined NN_ALLOC_MONITOR #define nn_alloc(size, name) nn_alloc_ (size, name) void *nn_alloc_ (size_t size, const char *name); #else #define nn_alloc(size, name) nn_alloc_(size) void *nn_alloc_ (size_t size); #endif #endif nanomsg-0.8-beta/src/utils/alloc.c0000664000175000017500000000725012623652600020033 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "alloc.h" #if defined NN_ALLOC_MONITOR #include "mutex.h" #include "int.h" #include #include #include struct nn_alloc_hdr { size_t size; const char *name; }; static struct nn_mutex nn_alloc_sync; static size_t nn_alloc_bytes; static size_t nn_alloc_blocks; void nn_alloc_init (void) { nn_mutex_init (&nn_alloc_sync); nn_alloc_bytes = 0; nn_alloc_blocks = 0; } void nn_alloc_term (void) { nn_mutex_term (&nn_alloc_sync); } void *nn_alloc_ (size_t size, const char *name) { uint8_t *chunk; chunk = malloc (sizeof (struct nn_alloc_hdr) + size); if (!chunk) return NULL; nn_mutex_lock (&nn_alloc_sync); ((struct nn_alloc_hdr*) chunk)->size = size; ((struct nn_alloc_hdr*) chunk)->name = name; nn_alloc_bytes += size; ++nn_alloc_blocks; printf ("Allocating %s (%zu bytes)\n", name, size); printf ("Current memory usage: %zu bytes in %zu blocks\n", nn_alloc_bytes, nn_alloc_blocks); nn_mutex_unlock (&nn_alloc_sync); return chunk + sizeof (struct nn_alloc_hdr); } void *nn_realloc (void *ptr, size_t size) { struct nn_alloc_hdr *oldchunk; struct nn_alloc_hdr *newchunk; size_t oldsize; oldchunk = ((struct nn_alloc_hdr*) ptr) - 1; oldsize = oldchunk->size; newchunk = realloc (oldchunk, sizeof (struct nn_alloc_hdr) + size); if (!newchunk) return NULL; newchunk->size = size; nn_mutex_lock (&nn_alloc_sync); nn_alloc_bytes -= oldsize; nn_alloc_bytes += size; printf ("Reallocating %s (%zu bytes to %zu bytes)\n", newchunk->name, oldsize, size); printf ("Current memory usage: %zu bytes in %zu blocks\n", nn_alloc_bytes, nn_alloc_blocks); nn_mutex_unlock (&nn_alloc_sync); return newchunk + sizeof (struct nn_alloc_hdr); } void nn_free (void *ptr) { struct nn_alloc_hdr *chunk; if (!ptr) return; chunk = ((struct nn_alloc_hdr*) ptr) - 1; nn_mutex_lock (&nn_alloc_sync); nn_alloc_bytes -= chunk->size; --nn_alloc_blocks; printf ("Deallocating %s (%zu bytes)\n", chunk->name, chunk->size); printf ("Current memory usage: %zu bytes in %zu blocks\n", nn_alloc_bytes, nn_alloc_blocks); nn_mutex_unlock (&nn_alloc_sync); free (chunk); } #else #include void nn_alloc_init (void) { } void nn_alloc_term (void) { } void *nn_alloc_ (size_t size) { return malloc (size); } void *nn_realloc (void *ptr, size_t size) { return realloc (ptr, size); } void nn_free (void *ptr) { free (ptr); } #endif nanomsg-0.8-beta/src/utils/atomic.h0000664000175000017500000000403112623652600020214 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_ATOMIC_INCLUDED #define NN_ATOMIC_INCLUDED #if defined NN_HAVE_WINDOWS #include "win.h" #define NN_ATOMIC_WINAPI #elif NN_HAVE_ATOMIC_SOLARIS #include #define NN_ATOMIC_SOLARIS #elif defined NN_HAVE_GCC_ATOMIC_BUILTINS #define NN_ATOMIC_GCC_BUILTINS #else #include "mutex.h" #define NN_ATOMIC_MUTEX #endif #include "int.h" struct nn_atomic { #if defined NN_ATOMIC_MUTEX struct nn_mutex sync; #endif volatile uint32_t n; }; /* Initialise the object. Set it to value 'n'. */ void nn_atomic_init (struct nn_atomic *self, uint32_t n); /* Destroy the object. */ void nn_atomic_term (struct nn_atomic *self); /* Atomically add n to the object, return old value of the object. */ uint32_t nn_atomic_inc (struct nn_atomic *self, uint32_t n); /* Atomically subtract n from the object, return old value of the object. */ uint32_t nn_atomic_dec (struct nn_atomic *self, uint32_t n); #endif nanomsg-0.8-beta/src/utils/atomic.c0000664000175000017500000000473712623652600020224 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "atomic.h" #include "err.h" void nn_atomic_init (struct nn_atomic *self, uint32_t n) { self->n = n; #if defined NN_ATOMIC_MUTEX nn_mutex_init (&self->sync); #endif } void nn_atomic_term (struct nn_atomic *self) { #if defined NN_ATOMIC_MUTEX nn_mutex_term (&self->sync); #endif } uint32_t nn_atomic_inc (struct nn_atomic *self, uint32_t n) { #if defined NN_ATOMIC_WINAPI return (uint32_t) InterlockedExchangeAdd ((LONG*) &self->n, n); #elif defined NN_ATOMIC_SOLARIS return atomic_add_32_nv (&self->n, n) - n; #elif defined NN_ATOMIC_GCC_BUILTINS return (uint32_t) __sync_fetch_and_add (&self->n, n); #elif defined NN_ATOMIC_MUTEX uint32_t res; nn_mutex_lock (&self->sync); res = self->n; self->n += n; nn_mutex_unlock (&self->sync); return res; #else #error #endif } uint32_t nn_atomic_dec (struct nn_atomic *self, uint32_t n) { #if defined NN_ATOMIC_WINAPI return (uint32_t) InterlockedExchangeAdd ((LONG*) &self->n, -((LONG) n)); #elif defined NN_ATOMIC_SOLARIS return atomic_add_32_nv (&self->n, -((int32_t) n)) + n; #elif defined NN_ATOMIC_GCC_BUILTINS return (uint32_t) __sync_fetch_and_sub (&self->n, n); #elif defined NN_ATOMIC_MUTEX uint32_t res; nn_mutex_lock (&self->sync); res = self->n; self->n -= n; nn_mutex_unlock (&self->sync); return res; #else #error #endif } nanomsg-0.8-beta/src/utils/attr.h0000664000175000017500000000247112623652600017720 0ustar00travistravis00000000000000/* Copyright (c) 2013 Insollo Entertainment, LLC. 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. */ #ifndef NN_ATTR_INCLUDED #define NN_ATTR_INCLUDED #if defined __GNUC__ || defined __llvm__ #define NN_UNUSED __attribute__ ((unused)) #else #define NN_UNUSED #endif #endif nanomsg-0.8-beta/src/utils/chunk.h0000664000175000017500000000365512623652600020063 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_CHUNK_INCLUDED #define NN_CHUNK_INCLUDED #include #include "int.h" /* Allocates the chunk using the allocation mechanism specified by 'type'. */ int nn_chunk_alloc (size_t size, int type, void **result); /* Resizes a chunk previously allocated with nn_chunk_alloc. */ int nn_chunk_realloc (size_t size, void **chunk); /* Releases a reference to the chunk and once the reference count had dropped to zero, deallocates the chunk. */ void nn_chunk_free (void *p); /* Increases the reference count of the chunk by 'n'. */ void nn_chunk_addref (void *p, uint32_t n); /* Returns size of the chunk buffer. */ size_t nn_chunk_size (void *p); /* Trims n bytes from the beginning of the chunk. Returns pointer to the new chunk. */ void *nn_chunk_trim (void *p, size_t n); #endif nanomsg-0.8-beta/src/utils/chunk.c0000664000175000017500000001450412623652600020051 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik All rights reserved. Copyright (c) 2014 Achille Roussel 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 "chunk.h" #include "atomic.h" #include "alloc.h" #include "fast.h" #include "wire.h" #include "err.h" #include #define NN_CHUNK_TAG 0xdeadcafe #define NN_CHUNK_TAG_DEALLOCATED 0xbeadfeed typedef void (*nn_chunk_free_fn) (void *p); struct nn_chunk { /* Number of places the chunk is referenced from. */ struct nn_atomic refcount; /* Size of the message in bytes. */ size_t size; /* Deallocation function. */ nn_chunk_free_fn ffn; /* The structure if followed by optional empty space, a 32 bit unsigned integer specifying the size of said empty space, a 32 bit tag and the message data itself. */ }; /* Private functions. */ static struct nn_chunk *nn_chunk_getptr (void *p); static void *nn_chunk_getdata (struct nn_chunk *c); static void nn_chunk_default_free (void *p); static size_t nn_chunk_hdrsize (); int nn_chunk_alloc (size_t size, int type, void **result) { size_t sz; struct nn_chunk *self; const size_t hdrsz = nn_chunk_hdrsize (); /* Compute total size to be allocated. Check for overflow. */ sz = hdrsz + size; if (nn_slow (sz < hdrsz)) return -ENOMEM; /* Allocate the actual memory depending on the type. */ switch (type) { case 0: self = nn_alloc (sz, "message chunk"); break; default: return -EINVAL; } if (nn_slow (!self)) return -ENOMEM; /* Fill in the chunk header. */ nn_atomic_init (&self->refcount, 1); self->size = size; self->ffn = nn_chunk_default_free; /* Fill in the size of the empty space between the chunk header and the message. */ nn_putl ((uint8_t*) ((uint32_t*) (self + 1)), 0); /* Fill in the tag. */ nn_putl ((uint8_t*) ((((uint32_t*) (self + 1))) + 1), NN_CHUNK_TAG); *result = nn_chunk_getdata (self); return 0; } int nn_chunk_realloc (size_t size, void **chunk) { struct nn_chunk *self; struct nn_chunk *new_chunk; void *new_ptr; size_t hdr_size; size_t new_size; int rc; self = nn_chunk_getptr (*chunk); /* Check if we only have one reference to this object, in that case we can reallocate the memory chunk. */ if (self->refcount.n == 1) { /* Compute new size, check for overflow. */ hdr_size = nn_chunk_hdrsize (); new_size = hdr_size + size; if (nn_slow (new_size < hdr_size)) return -ENOMEM; /* Reallocate memory chunk. */ new_chunk = nn_realloc (self, new_size); if (nn_slow (new_chunk == NULL)) return -ENOMEM; new_chunk->size = size; *chunk = nn_chunk_getdata (new_chunk); } /* There are many references to this memory chunk, we have to create a new one and copy the data. */ else { new_ptr = NULL; rc = nn_chunk_alloc (size, 0, &new_ptr); if (nn_slow (rc != 0)) { return rc; } memcpy (new_ptr, nn_chunk_getdata (self), self->size); *chunk = new_ptr; nn_atomic_dec (&self->refcount, 1); } return 0; } void nn_chunk_free (void *p) { struct nn_chunk *self; self = nn_chunk_getptr (p); /* Decrement the reference count. Actual deallocation happens only if it drops to zero. */ if (nn_atomic_dec (&self->refcount, 1) <= 1) { /* Mark chunk as deallocated. */ nn_putl ((uint8_t*) (((uint32_t*) p) - 1), NN_CHUNK_TAG_DEALLOCATED); /* Deallocate the resources held by the chunk. */ nn_atomic_term (&self->refcount); /* Deallocate the memory block according to the allocation mechanism specified. */ self->ffn (self); } } void nn_chunk_addref (void *p, uint32_t n) { struct nn_chunk *self; self = nn_chunk_getptr (p); nn_atomic_inc (&self->refcount, n); } size_t nn_chunk_size (void *p) { return nn_chunk_getptr (p)->size; } void *nn_chunk_trim (void *p, size_t n) { struct nn_chunk *self; const size_t hdrsz = sizeof (struct nn_chunk) + 2 * sizeof (uint32_t); size_t empty_space; self = nn_chunk_getptr (p); /* Sanity check. We cannot trim more bytes than there are in the chunk. */ nn_assert (n <= self->size); /* Adjust the chunk header. */ p = ((uint8_t*) p) + n; nn_putl ((uint8_t*) (((uint32_t*) p) - 1), NN_CHUNK_TAG); empty_space = (uint8_t*) p - (uint8_t*) self - hdrsz; nn_assert(empty_space < UINT32_MAX); nn_putl ((uint8_t*) (((uint32_t*) p) - 2), (uint32_t) empty_space); /* Adjust the size of the message. */ self->size -= n; return p; } static struct nn_chunk *nn_chunk_getptr (void *p) { uint32_t off; nn_assert (nn_getl ((uint8_t*) p - sizeof (uint32_t)) == NN_CHUNK_TAG); off = nn_getl ((uint8_t*) p - 2 * sizeof (uint32_t)); return (struct nn_chunk*) ((uint8_t*) p - 2 *sizeof (uint32_t) - off - sizeof (struct nn_chunk)); } static void *nn_chunk_getdata (struct nn_chunk *self) { return ((uint8_t*) (self + 1)) + 2 * sizeof (uint32_t); } static void nn_chunk_default_free (void *p) { nn_free (p); } static size_t nn_chunk_hdrsize () { return sizeof (struct nn_chunk) + 2 * sizeof (uint32_t); } nanomsg-0.8-beta/src/utils/chunkref.h0000664000175000017500000000733412623652600020556 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_CHUNKREF_INCLUDED #define NN_CHUNKREF_INCLUDED #define NN_CHUNKREF_MAX 32 #include "chunk.h" #include "int.h" #include /* This class represents a reference to a data chunk. It's either an actual reference to data allocated on the heap, or if short enough, it may store the data in itself. While user messages are not often short enough to store them inside the chunkref itself, SP protocol headers mostly are and thus we can avoid additional memory allocation per message. */ struct nn_chunkref { union { uint8_t ref [NN_CHUNKREF_MAX]; /* This option is present only to force alignemt of nn_chunkref to the word boudnary. */ void *unused; } u; }; /* Initialise the chunkref. The actual storage will be either on stack (for small messages, or will be allocated via nn_chunk object. */ void nn_chunkref_init (struct nn_chunkref *self, size_t size); /* Create a chunkref from an existing chunk object. */ void nn_chunkref_init_chunk (struct nn_chunkref *self, void *chunk); /* Deallocate the chunk. */ void nn_chunkref_term (struct nn_chunkref *self); /* Get the underlying chunk. If it doesn't exist (small messages) it allocates one. Chunkref points to empty chunk after the call. */ void *nn_chunkref_getchunk (struct nn_chunkref *self); /* Moves chunk content from src to dst. dst should not be initialised before calling this function. After the call, dst becomes initialised and src becomes uninitialised. */ void nn_chunkref_mv (struct nn_chunkref *dst, struct nn_chunkref *src); /* Copies chunk content from src to dst. dst should not be initialised before calling this function. */ void nn_chunkref_cp (struct nn_chunkref *dst, struct nn_chunkref *src); /* Returns the pointer to the binary data stored in the chunk. */ void *nn_chunkref_data (struct nn_chunkref *self); /* Returns the size of the binary data stored in the chunk. */ size_t nn_chunkref_size (struct nn_chunkref *self); /* Trims n bytes from the beginning of the chunk. */ void nn_chunkref_trim (struct nn_chunkref *self, size_t n); /* Bulk copying is done by first invoking nn_chunkref_bulkcopy_start on the source chunk and specifying how many copies of the chunk will be made. Then, nn_chunkref_bulkcopy_cp should be used 'copies' of times to make individual copies of the source chunk. Note: Using bulk copying is more efficient than making each copy separately. */ void nn_chunkref_bulkcopy_start (struct nn_chunkref *self, uint32_t copies); void nn_chunkref_bulkcopy_cp (struct nn_chunkref *dst, struct nn_chunkref *src); #endif nanomsg-0.8-beta/src/utils/chunkref.c0000664000175000017500000001061212623652600020542 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "chunkref.h" #include "err.h" #include /* nn_chunkref should be reinterpreted as this structure in case the first byte ('tag') is 0xff. */ struct nn_chunkref_chunk { uint8_t tag; void *chunk; }; /* Check whether VSM are small enough for size to fit into the first byte of the structure. */ CT_ASSERT (NN_CHUNKREF_MAX < 255); /* Check whether nn_chunkref_chunk fits into nn_chunkref. */ CT_ASSERT (sizeof (struct nn_chunkref) >= sizeof (struct nn_chunkref_chunk)); void nn_chunkref_init (struct nn_chunkref *self, size_t size) { int rc; struct nn_chunkref_chunk *ch; if (size < NN_CHUNKREF_MAX) { self->u.ref [0] = (uint8_t) size; return; } ch = (struct nn_chunkref_chunk*) self; ch->tag = 0xff; rc = nn_chunk_alloc (size, 0, &ch->chunk); errno_assert (rc == 0); } void nn_chunkref_init_chunk (struct nn_chunkref *self, void *chunk) { struct nn_chunkref_chunk *ch; ch = (struct nn_chunkref_chunk*) self; ch->tag = 0xff; ch->chunk = chunk; } void nn_chunkref_term (struct nn_chunkref *self) { struct nn_chunkref_chunk *ch; if (self->u.ref [0] == 0xff) { ch = (struct nn_chunkref_chunk*) self; nn_chunk_free (ch->chunk); } } void *nn_chunkref_getchunk (struct nn_chunkref *self) { int rc; struct nn_chunkref_chunk *ch; void *chunk; if (self->u.ref [0] == 0xff) { ch = (struct nn_chunkref_chunk*) self; self->u.ref [0] = 0; return ch->chunk; } rc = nn_chunk_alloc (self->u.ref [0], 0, &chunk); errno_assert (rc == 0); memcpy (chunk, &self->u.ref [1], self->u.ref [0]); self->u.ref [0] = 0; return chunk; } void nn_chunkref_mv (struct nn_chunkref *dst, struct nn_chunkref *src) { memcpy (dst, src, src->u.ref [0] == 0xff ? (int)sizeof (struct nn_chunkref_chunk) : src->u.ref [0] + 1); } void nn_chunkref_cp (struct nn_chunkref *dst, struct nn_chunkref *src) { struct nn_chunkref_chunk *ch; if (src->u.ref [0] == 0xff) { ch = (struct nn_chunkref_chunk*) src; nn_chunk_addref (ch->chunk, 1); } memcpy (dst, src, sizeof (struct nn_chunkref)); } void *nn_chunkref_data (struct nn_chunkref *self) { return self->u.ref [0] == 0xff ? ((struct nn_chunkref_chunk*) self)->chunk : &self->u.ref [1]; } size_t nn_chunkref_size (struct nn_chunkref *self) { return self->u.ref [0] == 0xff ? nn_chunk_size (((struct nn_chunkref_chunk*) self)->chunk) : self->u.ref [0]; } void nn_chunkref_trim (struct nn_chunkref *self, size_t n) { struct nn_chunkref_chunk *ch; if (self->u.ref [0] == 0xff) { ch = (struct nn_chunkref_chunk*) self; ch->chunk = nn_chunk_trim (ch->chunk, n); return; } nn_assert (self->u.ref [0] >= n); memmove (&self->u.ref [1], &self->u.ref [1 + n], self->u.ref [0] - n); self->u.ref [0] -= (uint8_t) n; } void nn_chunkref_bulkcopy_start (struct nn_chunkref *self, uint32_t copies) { struct nn_chunkref_chunk *ch; if (self->u.ref [0] == 0xff) { ch = (struct nn_chunkref_chunk*) self; nn_chunk_addref (ch->chunk, copies); } } void nn_chunkref_bulkcopy_cp (struct nn_chunkref *dst, struct nn_chunkref *src) { memcpy (dst, src, sizeof (struct nn_chunkref)); } nanomsg-0.8-beta/src/utils/clock.h0000664000175000017500000000340112623652600020033 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef NN_CLOCK_INCLUDED #define NN_CLOCK_INCLUDED #include "int.h" /* Optimised retrieval of the current time. The clock object is not thread-safe. */ struct nn_clock { uint64_t last_tsc; uint64_t last_time; }; /* Initialise the clock object. */ void nn_clock_init (struct nn_clock *self); /* Terminate the clock object. */ void nn_clock_term (struct nn_clock *self); /* Returns current time in milliseconds. */ uint64_t nn_clock_now (struct nn_clock *self); /* Returns an unique timestamp. If the system doesn't support producing timestamps the return value is zero. */ uint64_t nn_clock_timestamp (); #endif nanomsg-0.8-beta/src/utils/clock.c0000664000175000017500000001074312623652600020035 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik All rights reserved. Copyright (c) 2012 Julien Ammous 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. */ #if defined NN_HAVE_WINDOWS #include "win.h" #elif defined NN_HAVE_OSX #include #elif defined NN_HAVE_CLOCK_MONOTONIC || defined NN_HAVE_GETHRTIME #include #else #include #endif #include "clock.h" #include "fast.h" #include "err.h" #include "attr.h" /* 1 millisecond expressed in CPU ticks. The value is chosen is such a way that it works pretty well for CPU frequencies above 500MHz. */ #define NN_CLOCK_PRECISION 1000000 #if defined NN_HAVE_OSX static mach_timebase_info_data_t nn_clock_timebase_info; #endif static uint64_t nn_clock_rdtsc () { #if (defined _MSC_VER && (defined _M_IX86 || defined _M_X64)) return __rdtsc (); #elif (defined __GNUC__ && (defined __i386__ || defined __x86_64__)) uint32_t low; uint32_t high; __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high)); return (uint64_t) high << 32 | low; #elif (defined __SUNPRO_CC && (__SUNPRO_CC >= 0x5100) && (defined __i386 || \ defined __amd64 || defined __x86_64)) union { uint64_t u64val; uint32_t u32val [2]; } tsc; asm("rdtsc" : "=a" (tsc.u32val [0]), "=d" (tsc.u32val [1])); return tsc.u64val; #else /* RDTSC is not available. */ return 0; #endif } static uint64_t nn_clock_time () { #if defined NN_HAVE_WINDOWS LARGE_INTEGER tps; LARGE_INTEGER time; double tpms; QueryPerformanceFrequency (&tps); QueryPerformanceCounter (&time); tpms = (double) (tps.QuadPart / 1000); return (uint64_t) (time.QuadPart / tpms); #elif defined NN_HAVE_OSX uint64_t ticks; /* If the global timebase info is not initialised yet, init it. */ if (nn_slow (!nn_clock_timebase_info.denom)) mach_timebase_info (&nn_clock_timebase_info); ticks = mach_absolute_time (); return ticks * nn_clock_timebase_info.numer / nn_clock_timebase_info.denom / 1000000; #elif defined NN_HAVE_CLOCK_MONOTONIC int rc; struct timespec tv; rc = clock_gettime (CLOCK_MONOTONIC, &tv); errno_assert (rc == 0); return tv.tv_sec * (uint64_t) 1000 + tv.tv_nsec / 1000000; #elif defined NN_HAVE_GETHRTIME return gethrtime () / 1000000; #else int rc; struct timeval tv; /* Gettimeofday is slow on some systems. Moreover, it's not necessarily monotonic. Thus, it's used as a last resort mechanism. */ rc = gettimeofday (&tv, NULL); errno_assert (rc == 0); return tv.tv_sec * (uint64_t) 1000 + tv.tv_usec / 1000; #endif } void nn_clock_init (struct nn_clock *self) { self->last_tsc = nn_clock_rdtsc (); self->last_time = nn_clock_time (); } void nn_clock_term (NN_UNUSED struct nn_clock *self) { } uint64_t nn_clock_now (struct nn_clock *self) { /* If TSC is not supported, use the non-optimised time measurement. */ uint64_t tsc = nn_clock_rdtsc (); if (!tsc) return nn_clock_time (); /* If tsc haven't jumped back or run away too far, we can use the cached time value. */ if (nn_fast (tsc - self->last_tsc <= (NN_CLOCK_PRECISION / 2) && tsc >= self->last_tsc)) return self->last_time; /* It's a long time since we've last measured the time. We'll do a new measurement now. */ self->last_tsc = tsc; self->last_time = nn_clock_time (); return self->last_time; } uint64_t nn_clock_timestamp () { return nn_clock_rdtsc (); } nanomsg-0.8-beta/src/utils/closefd.h0000664000175000017500000000240212623652600020357 0ustar00travistravis00000000000000/* Copyright (c) 2013 GoPivotal, Inc. 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. */ #ifndef NN_CLOSEFD_INCLUDED #define NN_CLOSEFD_INCLUDED #if !defined NN_HAVE_WINDOWS void nn_closefd (int fd); #endif #endif nanomsg-0.8-beta/src/utils/closefd.c0000664000175000017500000000312012623652600020350 0ustar00travistravis00000000000000/* Copyright (c) 2013 GoPivotal, Inc. All rights reserved. Copyright 2015 Garrett D'Amore 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. */ #if !defined NN_HAVE_WINDOWS #include "closefd.h" #include "fast.h" #include "err.h" #include void nn_closefd (int fd) { int rc; if (nn_slow (fd < 0)) { return; } rc = close (fd); if (nn_fast (rc == 0)) return; errno_assert (errno == EINTR || errno == ETIMEDOUT || errno == EWOULDBLOCK || errno == EINPROGRESS || errno == ECONNRESET); } #endif nanomsg-0.8-beta/src/utils/cont.h0000664000175000017500000000272312623652600017711 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef NN_CONT_INCLUDED #define NN_CONT_INCLUDED #include /* Takes a pointer to a member variable and computes pointer to the structure that contains it. 'type' is type of the structure, not the member. */ #define nn_cont(ptr, type, member) \ (ptr ? ((type*) (((char*) ptr) - offsetof(type, member))) : NULL) #endif nanomsg-0.8-beta/src/utils/efd.h0000664000175000017500000000470212623652600017503 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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. */ #ifndef NN_EFD_INCLUDED #define NN_EFD_INCLUDED /* Provides a way to send signals via file descriptors. The important part is that nn_efd_getfd() returns an actual OS-level file descriptor that you can poll on to wait for the event. */ #include "fd.h" #if defined NN_HAVE_WINDOWS #include "efd_win.h" #elif defined NN_HAVE_EVENTFD #include "efd_eventfd.h" #elif defined NN_HAVE_PIPE #include "efd_pipe.h" #elif defined NN_HAVE_SOCKETPAIR #include "efd_socketpair.h" #else #error #endif /* Initialise the efd object. */ int nn_efd_init (struct nn_efd *self); /* Uninitialise the efd object. */ void nn_efd_term (struct nn_efd *self); /* Get the OS file descriptor that is readable when the efd object is signaled. */ nn_fd nn_efd_getfd (struct nn_efd *self); /* Stop the efd object. */ void nn_efd_stop (struct nn_efd *self); /* Switch the object into signaled state. */ void nn_efd_signal (struct nn_efd *self); /* Switch the object into unsignaled state. */ void nn_efd_unsignal (struct nn_efd *self); /* Wait till efd object becomes signaled or when timeout (in milliseconds, nagative value meaning 'infinite') expires. In the former case 0 is returened. In the latter, -ETIMEDOUT. */ int nn_efd_wait (struct nn_efd *self, int timeout); #endif nanomsg-0.8-beta/src/utils/efd.c0000664000175000017500000000543012623652600017475 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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 "efd.h" #if defined NN_HAVE_WINDOWS #include "efd_win.inc" #elif defined NN_HAVE_EVENTFD #include "efd_eventfd.inc" #elif defined NN_HAVE_PIPE #include "efd_pipe.inc" #elif defined NN_HAVE_SOCKETPAIR #include "efd_socketpair.inc" #else #error #endif #if defined NN_HAVE_POLL #include int nn_efd_wait (struct nn_efd *self, int timeout) { int rc; struct pollfd pfd; pfd.fd = nn_efd_getfd (self); pfd.events = POLLIN; if (nn_slow (pfd.fd < 0)) return -EBADF; rc = poll (&pfd, 1, timeout); if (nn_slow (rc < 0 && errno == EINTR)) return -EINTR; errno_assert (rc >= 0); if (nn_slow (rc == 0)) return -ETIMEDOUT; return 0; } #elif defined NN_HAVE_WINDOWS int nn_efd_wait (struct nn_efd *self, int timeout) { int rc; struct timeval tv; int fd = self->r; if (nn_slow (fd < 0)) { return -EBADF; } FD_SET (fd, &self->fds); if (timeout >= 0) { tv.tv_sec = timeout / 1000; tv.tv_usec = timeout % 1000 * 1000; } rc = select (0, &self->fds, NULL, NULL, timeout >= 0 ? &tv : NULL); if (nn_slow (rc == SOCKET_ERROR)) { rc = nn_err_wsa_to_posix (WSAGetLastError ()); errno = rc; /* Treat these as a non-fatal errors, typically occuring when the socket is being closed from a separate thread during a blocking I/O operation. */ if (nn_fast (rc == EINTR || rc == ENOTSOCK)) return -EINTR; } wsa_assert (rc >= 0); if (nn_slow (rc == 0)) return -ETIMEDOUT; return 0; } #else #error #endif nanomsg-0.8-beta/src/utils/efd_eventfd.h0000664000175000017500000000224512623652600021216 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ struct nn_efd { int efd; }; nanomsg-0.8-beta/src/utils/efd_eventfd.inc0000664000175000017500000000477712623652600021554 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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 "err.h" #include "int.h" #include "closefd.h" #include #include #include int nn_efd_init (struct nn_efd *self) { int rc; int flags; self->efd = eventfd (0, EFD_CLOEXEC); if (self->efd == -1 && (errno == EMFILE || errno == ENFILE)) return -EMFILE; errno_assert (self->efd != -1); flags = fcntl (self->efd, F_GETFL, 0); if (flags == -1) flags = 0; rc = fcntl (self->efd, F_SETFL, flags | O_NONBLOCK); errno_assert (rc != -1); return 0; } void nn_efd_term (struct nn_efd *self) { int fd = self->efd; self->efd = -1; nn_closefd (fd); } void nn_efd_stop (struct nn_efd *self) { nn_efd_signal (self); } nn_fd nn_efd_getfd (struct nn_efd *self) { return self->efd; } void nn_efd_signal (struct nn_efd *self) { const uint64_t one = 1; ssize_t nbytes; int fd = self->efd; if (nn_slow (fd < 0)) return; nbytes = write (fd, &one, sizeof (one)); errno_assert (nbytes == sizeof (one)); } void nn_efd_unsignal (struct nn_efd *self) { uint64_t count; int fd = self->efd; if (nn_slow (fd < 0)) return; /* Extract all the signals from the eventfd. */ ssize_t sz = read (fd, &count, sizeof (count)); errno_assert (sz >= 0); nn_assert (sz == sizeof (count)); } nanomsg-0.8-beta/src/utils/efd_pipe.h0000664000175000017500000000225612623652600020522 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ struct nn_efd { int r; int w; }; nanomsg-0.8-beta/src/utils/efd_pipe.inc0000664000175000017500000000624612623652600021047 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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 "err.h" #include "fast.h" #include "int.h" #include "closefd.h" #include #include #include #include int nn_efd_init (struct nn_efd *self) { int rc; int flags; int p [2]; #if defined NN_HAVE_PIPE2 rc = pipe2 (p, O_NONBLOCK | O_CLOEXEC); #else rc = pipe (p); #endif if (rc != 0 && (errno == EMFILE || errno == ENFILE)) return -EMFILE; errno_assert (rc == 0); self->r = p [0]; self->w = p [1]; #if !defined NN_HAVE_PIPE2 && defined FD_CLOEXEC rc = fcntl (self->r, F_SETFD, FD_CLOEXEC); errno_assert (rc != -1); rc = fcntl (self->w, F_SETFD, FD_CLOEXEC); errno_assert (rc != -1); #endif #if !defined NN_HAVE_PIPE2 flags = fcntl (self->r, F_GETFL, 0); if (flags == -1) flags = 0; rc = fcntl (self->r, F_SETFL, flags | O_NONBLOCK); errno_assert (rc != -1); #endif return 0; } void nn_efd_term (struct nn_efd *self) { /* Close the read side first. */ int fd = self->r; self->r = -1; nn_closefd (fd); fd = self->w; self->w = -1; nn_closefd (fd); } void nn_efd_stop (struct nn_efd *self) { /* Close the write side, which wakes up pollers with POLLHUP. */ int fd = self->w; self->w = -1; nn_closefd (fd); } nn_fd nn_efd_getfd (struct nn_efd *self) { return self->r; } void nn_efd_signal (struct nn_efd *self) { ssize_t nbytes; char c = 101; int fd = self->w; if (nn_slow (fd < 0)) return; nbytes = write (self->w, &c, 1); errno_assert (nbytes != -1); nn_assert (nbytes == 1); } void nn_efd_unsignal (struct nn_efd *self) { ssize_t nbytes; uint8_t buf [16]; while (1) { int fd = self->r; if (nn_slow (fd < 0)) return; nbytes = read (fd, buf, sizeof (buf)); if (nbytes < 0 && errno == EAGAIN) nbytes = 0; errno_assert (nbytes >= 0); if (nn_fast ((size_t) nbytes < sizeof (buf))) break; } } nanomsg-0.8-beta/src/utils/efd_socketpair.h0000664000175000017500000000230212623652600021721 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ typedef int nn_fd; struct nn_efd { int r; int w; }; nanomsg-0.8-beta/src/utils/efd_socketpair.inc0000664000175000017500000000623412623652600022253 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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 "err.h" #include "fast.h" #include "int.h" #include "closefd.h" #include #include #include #include int nn_efd_init (struct nn_efd *self) { int rc; int flags; int sp [2]; #if defined SOCK_CLOEXEC rc = socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sp); #else rc = socketpair (AF_UNIX, SOCK_STREAM, 0, sp); #endif if (rc != 0 && (errno == EMFILE || errno == ENFILE)) return -EMFILE; errno_assert (rc == 0); self->r = sp [0]; self->w = sp [1]; #if !defined SOCK_CLOEXEC && defined FD_CLOEXEC rc = fcntl (self->r, F_SETFD, FD_CLOEXEC); errno_assert (rc != -1); rc = fcntl (self->w, F_SETFD, FD_CLOEXEC); errno_assert (rc != -1); #endif flags = fcntl (self->r, F_GETFL, 0); if (flags == -1) flags = 0; rc = fcntl (self->r, F_SETFL, flags | O_NONBLOCK); errno_assert (rc != -1); return 0; } void nn_efd_stop (struct nn_efd *self) { int fd = self->w; self->w = -1; nn_closefd (fd); } void nn_efd_term (struct nn_efd *self) { int fd = self->r; self->r = -1; nn_closefd (fd); fd = self->w; self->w = -1; nn_closefd (fd); } nn_fd nn_efd_getfd (struct nn_efd *self) { return self->r; } void nn_efd_signal (struct nn_efd *self) { ssize_t nbytes; char c = 101; int fd = self->w; if (nn_slow (fd < 0)) return; #if defined MSG_NOSIGNAL nbytes = send (fd, &c, 1, MSG_NOSIGNAL); #else nbytes = send (fd, &c, 1, 0); #endif errno_assert (nbytes != -1); nn_assert (nbytes == 1); } void nn_efd_unsignal (struct nn_efd *self) { ssize_t nbytes; uint8_t buf [16]; while (1) { int fd = self->r; if (nn_slow (fd < 0)) return; nbytes = recv (self->r, buf, sizeof (buf), 0); if (nbytes < 0 && errno == EAGAIN) nbytes = 0; errno_assert (nbytes >= 0); if (nn_fast (nbytes < sizeof (buf))) break; } } nanomsg-0.8-beta/src/utils/efd_win.h0000664000175000017500000000232612623652600020360 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "win.h" struct nn_efd { SOCKET r; SOCKET w; fd_set fds; }; nanomsg-0.8-beta/src/utils/efd_win.inc0000664000175000017500000002044212623652600020701 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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. */ #define NN_EFD_PORT 5907 #define NN_EFD_RETRIES 1000 #include "err.h" #include "fast.h" #include "int.h" #include int nn_efd_init (struct nn_efd *self) { SECURITY_ATTRIBUTES sa = {0}; SECURITY_DESCRIPTOR sd; BOOL brc; HANDLE sync; DWORD dwrc; SOCKET listener; int rc; struct sockaddr_in addr; int addrlen; BOOL reuseaddr; BOOL nodelay; u_long nonblock; int i; /* Make the following critical section accessible to everyone. */ sa.nLength = sizeof (sa); sa.bInheritHandle = FALSE; brc = InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION); win_assert (brc); brc = SetSecurityDescriptorDacl(&sd, TRUE, (PACL) NULL, FALSE); win_assert (brc); sa.lpSecurityDescriptor = &sd; /* This function has to be enclosed in a system-wide critical section so that two instances of the library don't accidentally create an efd crossing the process boundary. */ sync = CreateMutex (&sa, FALSE, "Global\\nanomsg-port-mutex"); win_assert (sync != NULL); /* Enter the critical section. If we cannot get the object in 10 seconds then something is seriously wrong. Just bail. */ dwrc = WaitForSingleObject (sync, 10000); switch (dwrc) { case WAIT_ABANDONED: case WAIT_OBJECT_0: break; case WAIT_TIMEOUT: rc = ETIMEDOUT; goto wsafail3; default: rc = nn_err_wsa_to_posix (WSAGetLastError ()); goto wsafail3; } /* Unfortunately, on Windows the only way to send signal to a file descriptor (SOCKET) is to create a full-blown TCP connecting on top of the loopback interface. */ self->w = INVALID_SOCKET; self->r = INVALID_SOCKET; /* Create listening socket. */ listener = socket (AF_INET, SOCK_STREAM, 0); if (nn_slow (listener == SOCKET_ERROR)) goto wsafail; brc = SetHandleInformation ((HANDLE) listener, HANDLE_FLAG_INHERIT, 0); win_assert (brc); /* This prevents subsequent attempts to create a signaler to fail bacause of "TCP port in use" problem. */ reuseaddr = 1; rc = setsockopt (listener, SOL_SOCKET, SO_REUSEADDR, (char*) &reuseaddr, sizeof (reuseaddr)); if (nn_slow (rc == SOCKET_ERROR)) goto wsafail; /* Bind the listening socket to the local port. */ memset (&addr, 0, sizeof (addr)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); addr.sin_port = htons (NN_EFD_PORT); rc = bind (listener, (const struct sockaddr*) &addr, sizeof (addr)); if (nn_slow (rc == SOCKET_ERROR)) goto wsafail; /* Start listening for the incomming connections. In normal case we are going to accept just a single connection, so backlog buffer of size 1 is sufficient. */ rc = listen (listener, 1); if (nn_slow (rc == SOCKET_ERROR)) goto wsafail; /* The following code is in the loop, because windows sometimes delays WSAEADDRINUSE error to the `connect` call. But retrying the connection works like a charm. Still we want to limit number of retries */ for(i = 0; i < NN_EFD_RETRIES; ++i) { /* Create the writer socket. */ self->w = socket (AF_INET, SOCK_STREAM, 0); if (nn_slow (listener == SOCKET_ERROR)) goto wsafail; brc = SetHandleInformation ((HANDLE) self->w, HANDLE_FLAG_INHERIT, 0); win_assert (brc); /* Set TCP_NODELAY on the writer socket to make efd as fast as possible. There's only one byte going to be written, so batching would not make sense anyway. */ nodelay = 1; rc = setsockopt (self->w, IPPROTO_TCP, TCP_NODELAY, (char*) &nodelay, sizeof (nodelay)); if (nn_slow (rc == SOCKET_ERROR)) goto wsafail; /* Connect the writer socket to the listener socket. */ rc = connect (self->w, (struct sockaddr*) &addr, sizeof (addr)); if (nn_slow (rc == SOCKET_ERROR)) { rc = nn_err_wsa_to_posix (WSAGetLastError ()); if (rc == EADDRINUSE) { rc = closesocket (self->w); if (nn_slow (rc == INVALID_SOCKET)) goto wsafail; continue; } goto wsafail2; } break; } if (i == NN_EFD_RETRIES) goto wsafail2; for (;;) { /* Accept new incoming connection. */ addrlen = sizeof (addr); self->r = accept (listener, (struct sockaddr*) &addr, &addrlen); if (nn_slow (self->r == INVALID_SOCKET || addrlen != sizeof (addr))) goto wsafail2; /* Check that the connection actually comes from the localhost. */ if (nn_fast (addr.sin_addr.s_addr == htonl (INADDR_LOOPBACK))) break; /* If not so, close the connection and try again. */ rc = closesocket (self->r); if (nn_slow (rc == INVALID_SOCKET)) goto wsafail; } /* Listener socket can be closed now as no more connections for this efd are going to be established anyway. */ rc = closesocket (listener); if (nn_slow (rc == INVALID_SOCKET)) goto wsafail; /* Leave the critical section. */ brc = ReleaseMutex (sync); win_assert (brc != 0); brc = CloseHandle (sync); win_assert (brc != 0); /* Make the receiving socket non-blocking. */ nonblock = 1; rc = ioctlsocket (self->r, FIONBIO, &nonblock); wsa_assert (rc != SOCKET_ERROR); /* Initialise the pre-allocated pollset. */ FD_ZERO (&self->fds); return 0; wsafail: rc = nn_err_wsa_to_posix (WSAGetLastError ()); wsafail2: brc = ReleaseMutex (sync); win_assert (brc != 0); wsafail3: brc = CloseHandle (sync); win_assert (brc != 0); return -rc; } void nn_efd_stop (struct nn_efd *self) { int rc; SOCKET s = self->w; self->w = INVALID_SOCKET; if (s != INVALID_SOCKET) { rc = closesocket (s); wsa_assert (rc != INVALID_SOCKET); } } void nn_efd_term (struct nn_efd *self) { int rc; SOCKET s; s = self->r; self->r = INVALID_SOCKET; if (s != INVALID_SOCKET) { rc = closesocket (s); wsa_assert (rc != INVALID_SOCKET); } s = self->w; self->w = INVALID_SOCKET; if (s != INVALID_SOCKET) { rc = closesocket (s); wsa_assert (rc != INVALID_SOCKET); } } nn_fd nn_efd_getfd (struct nn_efd *self) { return self->r; } void nn_efd_signal (struct nn_efd *self) { int rc; unsigned char c = 0xec; SOCKET s = self->w; if (nn_fast (s != INVALID_SOCKET)) { rc = send (s, (char*) &c, 1, 0); wsa_assert (rc != SOCKET_ERROR); nn_assert (rc == 1); } } void nn_efd_unsignal (struct nn_efd *self) { int rc; uint8_t buf [16]; while (1) { SOCKET s = self->r; if (nn_slow (s == INVALID_SOCKET)) break; rc = recv (s, (char*) buf, sizeof (buf), 0); if (rc == SOCKET_ERROR && WSAGetLastError () == WSAEWOULDBLOCK) rc = 0; wsa_assert (rc != SOCKET_ERROR); if (nn_fast (rc < sizeof (buf))) break; } } nanomsg-0.8-beta/src/utils/err.h0000664000175000017500000001240312623652600017532 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef NN_ERR_INCLUDED #define NN_ERR_INCLUDED #include #include #include /* Include nn.h header to define nanomsg-specific error codes. */ #include "../nn.h" #include "fast.h" #if defined _MSC_VER #define NN_NORETURN __declspec(noreturn) #elif defined __GNUC__ #define NN_NORETURN __attribute__ ((noreturn)) #else #define NN_NORETURN #endif /* Same as system assert(). However, under Win32 assert has some deficiencies. Thus this macro. */ #define nn_assert(x) \ do {\ if (nn_slow (!(x))) {\ fprintf (stderr, "Assertion failed: %s (%s:%d)\n", #x, \ __FILE__, __LINE__);\ fflush (stderr);\ nn_err_abort ();\ }\ } while (0) #define nn_assert_state(obj, state_name) \ do {\ if (nn_slow ((obj)->state != state_name)) {\ fprintf (stderr, \ "Assertion failed: %d == %s (%s:%d)\n", \ (obj)->state, #state_name, \ __FILE__, __LINE__);\ fflush (stderr);\ nn_err_abort ();\ }\ } while (0) /* Checks whether memory allocation was successful. */ #define alloc_assert(x) \ do {\ if (nn_slow (!x)) {\ fprintf (stderr, "Out of memory (%s:%d)\n",\ __FILE__, __LINE__);\ fflush (stderr);\ nn_err_abort ();\ }\ } while (0) /* Check the condition. If false prints out the errno. */ #define errno_assert(x) \ do {\ if (nn_slow (!(x))) {\ fprintf (stderr, "%s [%d] (%s:%d)\n", nn_err_strerror (errno),\ (int) errno, __FILE__, __LINE__);\ fflush (stderr);\ nn_err_abort ();\ }\ } while (0) /* Checks whether supplied errno number is an error. */ #define errnum_assert(cond, err) \ do {\ if (nn_slow (!(cond))) {\ fprintf (stderr, "%s [%d] (%s:%d)\n", nn_err_strerror (err),\ (int) (err), __FILE__, __LINE__);\ fflush (stderr);\ nn_err_abort ();\ }\ } while (0) /* Checks the condition. If false prints out the GetLastError info. */ #define win_assert(x) \ do {\ if (nn_slow (!(x))) {\ char errstr [256];\ nn_win_error ((int) GetLastError (), errstr, 256);\ fprintf (stderr, "%s [%d] (%s:%d)\n",\ errstr, (int) GetLastError (), __FILE__, __LINE__);\ fflush (stderr);\ nn_err_abort ();\ }\ } while (0) /* Checks the condition. If false prints out the WSAGetLastError info. */ #define wsa_assert(x) \ do {\ if (nn_slow (!(x))) {\ char errstr [256];\ nn_win_error (WSAGetLastError (), errstr, 256);\ fprintf (stderr, "%s [%d] (%s:%d)\n",\ errstr, (int) WSAGetLastError (), __FILE__, __LINE__);\ fflush (stderr);\ nn_err_abort ();\ }\ } while (0) /* Assertion-like macros for easier fsm debugging. */ #define nn_fsm_error(message, state, src, type) \ do {\ fprintf (stderr, "%s: state=%d source=%d action=%d (%s:%d)\n", \ message, state, src, type, __FILE__, __LINE__);\ fflush (stderr);\ nn_err_abort ();\ } while (0) #define nn_fsm_bad_action(state, src, type) nn_fsm_error(\ "Unexpected action", state, src, type) #define nn_fsm_bad_state(state, src, type) nn_fsm_error(\ "Unexpected state", state, src, type) #define nn_fsm_bad_source(state, src, type) nn_fsm_error(\ "Unexpected source", state, src, type) /* Compile-time assert. */ #define CT_ASSERT_HELPER2(prefix, line) prefix##line #define CT_ASSERT_HELPER1(prefix, line) CT_ASSERT_HELPER2(prefix, line) #if defined __COUNTER__ #define CT_ASSERT(x) \ typedef int CT_ASSERT_HELPER1(ct_assert_,__COUNTER__) [(x) ? 1 : -1] #else #define CT_ASSERT(x) \ typedef int CT_ASSERT_HELPER1(ct_assert_,__LINE__) [(x) ? 1 : -1] #endif NN_NORETURN void nn_err_abort (void); int nn_err_errno (void); const char *nn_err_strerror (int errnum); #ifdef NN_HAVE_WINDOWS int nn_err_wsa_to_posix (int wsaerr); void nn_win_error (int err, char *buf, size_t bufsize); #endif #endif nanomsg-0.8-beta/src/utils/err.c0000664000175000017500000001176512623652600017537 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "err.h" #ifdef NN_HAVE_WINDOWS #include "win.h" #endif #include void nn_err_abort (void) { abort (); } int nn_err_errno (void) { return errno; } const char *nn_err_strerror (int errnum) { switch (errnum) { #if defined NN_HAVE_WINDOWS case ENOTSUP: return "Not supported"; case EPROTONOSUPPORT: return "Protocol not supported"; case ENOBUFS: return "No buffer space available"; case ENETDOWN: return "Network is down"; case EADDRINUSE: return "Address in use"; case EADDRNOTAVAIL: return "Address not available"; case ECONNREFUSED: return "Connection refused"; case EINPROGRESS: return "Operation in progress"; case ENOTSOCK: return "Not a socket"; case EAFNOSUPPORT: return "Address family not supported"; case EPROTO: return "Protocol error"; case EAGAIN: return "Resource unavailable, try again"; case EBADF: return "Bad file descriptor"; case EINVAL: return "Invalid argument"; case EMFILE: return "Too many open files"; case EFAULT: return "Bad address"; case EACCES: return "Permission denied"; case ENETRESET: return "Connection aborted by network"; case ENETUNREACH: return "Network unreachable"; case EHOSTUNREACH: return "Host is unreachable"; case ENOTCONN: return "The socket is not connected"; case EMSGSIZE: return "Message too large"; case ETIMEDOUT: return "Timed out"; case ECONNABORTED: return "Connection aborted"; case ECONNRESET: return "Connection reset"; case ENOPROTOOPT: return "Protocol not available"; case EISCONN: return "Socket is connected"; #endif case ETERM: return "Nanomsg library was terminated"; case EFSM: return "Operation cannot be performed in this state"; default: #if defined _MSC_VER #pragma warning (push) #pragma warning (disable:4996) #endif return strerror (errnum); #if defined _MSC_VER #pragma warning (pop) #endif } } #ifdef NN_HAVE_WINDOWS int nn_err_wsa_to_posix (int wsaerr) { switch (wsaerr) { case WSAEINPROGRESS: return EAGAIN; case WSAEBADF: return EBADF; case WSAEINVAL: return EINVAL; case WSAEMFILE: return EMFILE; case WSAEFAULT: return EFAULT; case WSAEPROTONOSUPPORT: return EPROTONOSUPPORT; case WSAENOBUFS: return ENOBUFS; case WSAENETDOWN: return ENETDOWN; case WSAEADDRINUSE: return EADDRINUSE; case WSAEADDRNOTAVAIL: return EADDRNOTAVAIL; case WSAEAFNOSUPPORT: return EAFNOSUPPORT; case WSAEACCES: return EACCES; case WSAENETRESET: return ENETRESET; case WSAENETUNREACH: return ENETUNREACH; case WSAEHOSTUNREACH: return EHOSTUNREACH; case WSAENOTCONN: return ENOTCONN; case WSAEMSGSIZE: return EMSGSIZE; case WSAETIMEDOUT: return ETIMEDOUT; case WSAECONNREFUSED: return ECONNREFUSED; case WSAECONNABORTED: return ECONNABORTED; case WSAECONNRESET: return ECONNRESET; case WSAENOTSOCK: return ENOTSOCK; case ERROR_BROKEN_PIPE: return ECONNRESET; case WSAESOCKTNOSUPPORT: return ESOCKTNOSUPPORT; case ERROR_NOT_CONNECTED: return ENOTCONN; case ERROR_PIPE_NOT_CONNECTED: return ENOTCONN; case ERROR_NO_DATA: return EPIPE; default: nn_assert (0); } } void nn_win_error (int err, char *buf, size_t bufsize) { DWORD rc = FormatMessageA ( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, (DWORD) err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, (DWORD) bufsize, NULL ); nn_assert (rc); } #endif nanomsg-0.8-beta/src/utils/fast.h0000664000175000017500000000256712623652600017711 0ustar00travistravis00000000000000/* Copyright (c) 2012Martin Sustrik 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. */ #ifndef NN_FAST_INCLUDED #define NN_FAST_INCLUDED #if defined __GNUC__ || defined __llvm__ #define nn_fast(x) __builtin_expect ((x), 1) #define nn_slow(x) __builtin_expect ((x), 0) #else #define nn_fast(x) (x) #define nn_slow(x) (x) #endif #endif nanomsg-0.8-beta/src/utils/fd.h0000664000175000017500000000245212623652600017336 0ustar00travistravis00000000000000/* Copyright (c) 2013 Immanuel Weber, Fraunhofer FHR/AMLS 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. */ #ifndef NN_FD_INCLUDED #define NN_FD_INCLUDED #ifdef NN_HAVE_WINDOWS #include "win.h" typedef SOCKET nn_fd; #else typedef int nn_fd; #endif #endif nanomsg-0.8-beta/src/utils/glock.h0000664000175000017500000000262012623652600020041 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef NN_GLOCK_INCLUDED #define NN_GLOCK_INCLUDED /* Implementation of a global lock (critical section). The lock is meant to be used to synchronise the initialisation/termination of the library. */ void nn_glock_lock (void); void nn_glock_unlock (void); #endif nanomsg-0.8-beta/src/utils/glock.c0000664000175000017500000000376312623652600020045 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "glock.h" #if defined NN_HAVE_WINDOWS #include "win.h" #include "err.h" static LONG nn_glock_initialised = 0; static CRITICAL_SECTION nn_glock_cs; static void nn_glock_init (void) { if (InterlockedCompareExchange (&nn_glock_initialised, 1, 0) == 0) InitializeCriticalSection (&nn_glock_cs); } void nn_glock_lock (void) { nn_glock_init (); EnterCriticalSection (&nn_glock_cs); } void nn_glock_unlock (void) { nn_glock_init (); LeaveCriticalSection (&nn_glock_cs); } #else #include "err.h" #include static pthread_mutex_t nn_glock_mutex = PTHREAD_MUTEX_INITIALIZER; void nn_glock_lock (void) { int rc; rc = pthread_mutex_lock (&nn_glock_mutex); errnum_assert (rc == 0, rc); } void nn_glock_unlock (void) { int rc; rc = pthread_mutex_unlock (&nn_glock_mutex); errnum_assert (rc == 0, rc); } #endif nanomsg-0.8-beta/src/utils/hash.h0000664000175000017500000000467712623652600017703 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_HASH_INCLUDED #define NN_HASH_INCLUDED #include "list.h" #include "int.h" #include /* Use for initialising a hash item statically. */ #define NN_HASH_ITEM_INITIALIZER {0xffff, NN_LIST_ITEM_INITILIZER} struct nn_hash_item { uint32_t key; struct nn_list_item list; }; struct nn_hash { uint32_t slots; uint32_t items; struct nn_list *array; }; /* Initialise the hash table. */ void nn_hash_init (struct nn_hash *self); /* Terminate the hash. Note that hash must be manually emptied before the termination. */ void nn_hash_term (struct nn_hash *self); /* Adds an item to the hash. */ void nn_hash_insert (struct nn_hash *self, uint32_t key, struct nn_hash_item *item); /* Removes the element from the hash it is in at the moment. */ void nn_hash_erase (struct nn_hash *self, struct nn_hash_item *item); /* Gets an item in the hash based on the key. Returns NULL if there's no corresponing item in the hash table. */ struct nn_hash_item *nn_hash_get (struct nn_hash *self, uint32_t key); /* Initialise a hash item. At this point it is not a part of any hash table. */ void nn_hash_item_init (struct nn_hash_item *self); /* Terminate a hash item. The item must not be in a hash table prior to this call. */ void nn_hash_item_term (struct nn_hash_item *self); #endif nanomsg-0.8-beta/src/utils/hash.c0000664000175000017500000001142312623652600017661 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "hash.h" #include "fast.h" #include "alloc.h" #include "cont.h" #include "err.h" #define NN_HASH_INITIAL_SLOTS 32 static uint32_t nn_hash_key (uint32_t key); void nn_hash_init (struct nn_hash *self) { uint32_t i; self->slots = NN_HASH_INITIAL_SLOTS; self->items = 0; self->array = nn_alloc (sizeof (struct nn_list) * NN_HASH_INITIAL_SLOTS, "hash map"); alloc_assert (self->array); for (i = 0; i != NN_HASH_INITIAL_SLOTS; ++i) nn_list_init (&self->array [i]); } void nn_hash_term (struct nn_hash *self) { uint32_t i; for (i = 0; i != self->slots; ++i) nn_list_term (&self->array [i]); nn_free (self->array); } static void nn_hash_rehash (struct nn_hash *self) { uint32_t i; uint32_t oldslots; struct nn_list *oldarray; struct nn_hash_item *hitm; uint32_t newslot; /* Allocate new double-sized array of slots. */ oldslots = self->slots; oldarray = self->array; self->slots *= 2; self->array = nn_alloc (sizeof (struct nn_list) * self->slots, "hash map"); alloc_assert (self->array); for (i = 0; i != self->slots; ++i) nn_list_init (&self->array [i]); /* Move the items from old slot array to new slot array. */ for (i = 0; i != oldslots; ++i) { while (!nn_list_empty (&oldarray [i])) { hitm = nn_cont (nn_list_begin (&oldarray [i]), struct nn_hash_item, list); nn_list_erase (&oldarray [i], &hitm->list); newslot = nn_hash_key (hitm->key) % self->slots; nn_list_insert (&self->array [newslot], &hitm->list, nn_list_end (&self->array [newslot])); } nn_list_term (&oldarray [i]); } /* Deallocate the old array of slots. */ nn_free (oldarray); } void nn_hash_insert (struct nn_hash *self, uint32_t key, struct nn_hash_item *item) { struct nn_list_item *it; uint32_t i; i = nn_hash_key (key) % self->slots; for (it = nn_list_begin (&self->array [i]); it != nn_list_end (&self->array [i]); it = nn_list_next (&self->array [i], it)) nn_assert (nn_cont (it, struct nn_hash_item, list)->key != key); item->key = key; nn_list_insert (&self->array [i], &item->list, nn_list_end (&self->array [i])); ++self->items; /* If the hash is getting full, double the amount of slots and re-hash all the items. */ if (nn_slow (self->items * 2 > self->slots && self->slots < 0x80000000)) nn_hash_rehash(self); } void nn_hash_erase (struct nn_hash *self, struct nn_hash_item *item) { uint32_t slot; slot = nn_hash_key (item->key) % self->slots; nn_list_erase (&self->array [slot], &item->list); --self->items; } struct nn_hash_item *nn_hash_get (struct nn_hash *self, uint32_t key) { uint32_t slot; struct nn_list_item *it; struct nn_hash_item *item; slot = nn_hash_key (key) % self->slots; for (it = nn_list_begin (&self->array [slot]); it != nn_list_end (&self->array [slot]); it = nn_list_next (&self->array [slot], it)) { item = nn_cont (it, struct nn_hash_item, list); if (item->key == key) return item; } return NULL; } uint32_t nn_hash_key (uint32_t key) { /* TODO: This is a randomly chosen hashing function. Give some thought to picking a more fitting one. */ key = (key ^ 61) ^ (key >> 16); key += key << 3; key = key ^ (key >> 4); key = key * 0x27d4eb2d; key = key ^ (key >> 15); return key; } void nn_hash_item_init (struct nn_hash_item *self) { nn_list_item_init (&self->list); } void nn_hash_item_term (struct nn_hash_item *self) { nn_list_item_term (&self->list); } nanomsg-0.8-beta/src/utils/int.h0000664000175000017500000000541712623652600017543 0ustar00travistravis00000000000000/* Copyright (c) 2013 GoPivotal, Inc. 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. */ #ifndef NN_INT_INCLUDED #define NN_INT_INCLUDED #if defined NN_HAVE_WINDOWS && !defined NN_HAVE_STDINT /* Old versions of MSVC don't ship with stdint.h header file. Thus, we have to define fix-sized integer type ourselves. */ #ifndef int8_t typedef __int8 int8_t; #endif #ifndef uint8_t typedef unsigned __int8 uint8_t; #endif #ifndef int16_t typedef __int16 int16_t; #endif #ifndef uint16_t typedef unsigned __int16 uint16_t; #endif #ifndef int32_t typedef __int32 int32_t; #endif #ifndef uint32_t typedef unsigned __int32 uint32_t; #endif #ifndef int64_t typedef __int64 int64_t; #endif #ifndef uint64_t typedef unsigned __int64 uint64_t; #endif #ifndef INT8_MIN #define INT8_MIN 0x80i8 #endif #ifndef INT16_MIN #define INT16_MIN 0x8000i16 #endif #ifndef INT32_MIN #define INT32_MIN 0x80000000i32 #endif #ifndef INT64_MIN #define INT64_MIN 0x8000000000000000i64 #endif #ifndef INT8_MAX #define INT8_MAX 0x7fi8 #endif #ifndef INT16_MAX #define INT16_MAX 0x7fffi16 #endif #ifndef INT32_MAX #define INT32_MAX 0x7fffffffi32 #endif #ifndef INT64_MAX #define INT64_MAX 0x7fffffffffffffffi64 #endif #ifndef UINT8_MAX #define UINT8_MAX 0xffui8 #endif #ifndef UINT16_MAX #define UINT16_MAX 0xffffui16 #endif #ifndef UINT32_MAX #define UINT32_MAX 0xffffffffui32 #endif #ifndef UINT64_MAX #define UINT64_MAX 0xffffffffffffffffui64 #endif #elif defined NN_HAVE_SOLARIS || defined NN_HAVE_OPENVMS /* Solaris and OpenVMS don't have standard stdint.h header, rather the fixed integer types are defined in inttypes.h. */ #include #else /* Fully POSIX-compliant platforms have fixed integer types defined in stdint.h. */ #include #endif #endif nanomsg-0.8-beta/src/utils/list.h0000664000175000017500000000637712623652600017732 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef NN_LIST_INCLUDED #define NN_LIST_INCLUDED struct nn_list_item { struct nn_list_item *next; struct nn_list_item *prev; }; struct nn_list { struct nn_list_item *first; struct nn_list_item *last; }; /* Undefined value for initializing a list item which is not part of a list. */ #define NN_LIST_NOTINLIST ((struct nn_list_item*) -1) /* Use for initializing a list item statically. */ #define NN_LIST_ITEM_INITIALIZER {NN_LIST_NOTINLIST, NN_LIST_NOTINLIST} /* Initialise the list. */ void nn_list_init (struct nn_list *self); /* Terminates the list. Note that all items must be removed before the termination. */ void nn_list_term (struct nn_list *self); /* Returns 1 is list has zero items, 0 otherwise. */ int nn_list_empty (struct nn_list *self); /* Returns iterator to the first item in the list. */ struct nn_list_item *nn_list_begin (struct nn_list *self); /* Returns iterator to one past the last item in the list. */ struct nn_list_item *nn_list_end (struct nn_list *self); /* Returns iterator to an item prior to the one pointed to by 'it'. */ struct nn_list_item *nn_list_prev (struct nn_list *self, struct nn_list_item *it); /* Returns iterator to one past the item pointed to by 'it'. */ struct nn_list_item *nn_list_next (struct nn_list *self, struct nn_list_item *it); /* Adds the item to the list before the item pointed to by 'it'. Priot to insertion item should not be part of any list. */ void nn_list_insert (struct nn_list *self, struct nn_list_item *item, struct nn_list_item *it); /* Removes the item from the list and returns pointer to the next item in the list. Item must be part of the list. */ struct nn_list_item *nn_list_erase (struct nn_list *self, struct nn_list_item *item); /* Initialize a list item. At this point it is not part of any list. */ void nn_list_item_init (struct nn_list_item *self); /* Terminates a list item. Item must not be part of any list before it's terminated. */ void nn_list_item_term (struct nn_list_item *self); /* Returns 1 is the item is part of a list, 0 otherwise. */ int nn_list_item_isinlist (struct nn_list_item *self); #endif nanomsg-0.8-beta/src/utils/list.c0000664000175000017500000000637712623652600017725 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 #include "list.h" #include "err.h" #include "attr.h" void nn_list_init (struct nn_list *self) { self->first = NULL; self->last = NULL; } void nn_list_term (struct nn_list *self) { nn_assert (self->first == NULL); nn_assert (self->last == NULL); } int nn_list_empty (struct nn_list *self) { return self->first ? 0 : 1; } struct nn_list_item *nn_list_begin (struct nn_list *self) { return self->first; } struct nn_list_item *nn_list_end (NN_UNUSED struct nn_list *self) { return NULL; } struct nn_list_item *nn_list_prev (struct nn_list *self, struct nn_list_item *it) { if (!it) return self->last; nn_assert (it->prev != NN_LIST_NOTINLIST); return it->prev; } struct nn_list_item *nn_list_next (NN_UNUSED struct nn_list *self, struct nn_list_item *it) { nn_assert (it->next != NN_LIST_NOTINLIST); return it->next; } void nn_list_insert (struct nn_list *self, struct nn_list_item *item, struct nn_list_item *it) { nn_assert (!nn_list_item_isinlist (item)); item->prev = it ? it->prev : self->last; item->next = it; if (item->prev) item->prev->next = item; if (item->next) item->next->prev = item; if (!self->first || self->first == it) self->first = item; if (!it) self->last = item; } struct nn_list_item *nn_list_erase (struct nn_list *self, struct nn_list_item *item) { struct nn_list_item *next; nn_assert (nn_list_item_isinlist (item)); if (item->prev) item->prev->next = item->next; else self->first = item->next; if (item->next) item->next->prev = item->prev; else self->last = item->prev; next = item->next; item->prev = NN_LIST_NOTINLIST; item->next = NN_LIST_NOTINLIST; return next; } void nn_list_item_init (struct nn_list_item *self) { self->prev = NN_LIST_NOTINLIST; self->next = NN_LIST_NOTINLIST; } void nn_list_item_term (struct nn_list_item *self) { nn_assert (!nn_list_item_isinlist (self)); } int nn_list_item_isinlist (struct nn_list_item *self) { return self->prev == NN_LIST_NOTINLIST ? 0 : 1; } nanomsg-0.8-beta/src/utils/msg.h0000664000175000017500000000621612623652600017535 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_MSG_INCLUDED #define NN_MSG_INCLUDED #include "chunkref.h" #include struct nn_msg { /* Contains SP message header. This field directly corresponds to SP message header as defined in SP RFCs. There's no leading cmsghdr or trailing padding. */ struct nn_chunkref sphdr; /* Contains any additional transport-level message headers. Format of this buffer is a list of cmsgs as defined by POSIX (see "ancillary data"). */ struct nn_chunkref hdrs; /* Contains application level message payload. */ struct nn_chunkref body; }; /* Initialises a message with body 'size' bytes long and empty header. */ void nn_msg_init (struct nn_msg *self, size_t size); /* Initialise message with body provided in the form of chunk pointer. */ void nn_msg_init_chunk (struct nn_msg *self, void *chunk); /* Frees resources allocate with the message. */ void nn_msg_term (struct nn_msg *self); /* Moves the content of the message from src to dst. dst should not be initialised prior to the operation. src will be uninitialised after the operation. */ void nn_msg_mv (struct nn_msg *dst, struct nn_msg *src); /* Copies a message from src to dst. dst should not be initialised prior to the operation. */ void nn_msg_cp (struct nn_msg *dst, struct nn_msg *src); /* Bulk copying is done by first invoking nn_msg_bulkcopy_start on the source message and specifying how many copies of the message will be made. Then, nn_msg_bulkcopy_cp should be used 'copies' of times to make individual copies of the source message. Note: Bulk copying is more efficient than making each copy separately. */ void nn_msg_bulkcopy_start (struct nn_msg *self, uint32_t copies); void nn_msg_bulkcopy_cp (struct nn_msg *dst, struct nn_msg *src); /** Replaces the message body with entirely new data. This allows protocols that substantially rewrite or preprocess the userland message to be written. */ void nn_msg_replace_body(struct nn_msg *self, struct nn_chunkref newBody); #endif nanomsg-0.8-beta/src/utils/msg.c0000664000175000017500000000524612623652600017532 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "msg.h" #include void nn_msg_init (struct nn_msg *self, size_t size) { nn_chunkref_init (&self->sphdr, 0); nn_chunkref_init (&self->hdrs, 0); nn_chunkref_init (&self->body, size); } void nn_msg_init_chunk (struct nn_msg *self, void *chunk) { nn_chunkref_init (&self->sphdr, 0); nn_chunkref_init (&self->hdrs, 0); nn_chunkref_init_chunk (&self->body, chunk); } void nn_msg_term (struct nn_msg *self) { nn_chunkref_term (&self->sphdr); nn_chunkref_term (&self->hdrs); nn_chunkref_term (&self->body); } void nn_msg_mv (struct nn_msg *dst, struct nn_msg *src) { nn_chunkref_mv (&dst->sphdr, &src->sphdr); nn_chunkref_mv (&dst->hdrs, &src->hdrs); nn_chunkref_mv (&dst->body, &src->body); } void nn_msg_cp (struct nn_msg *dst, struct nn_msg *src) { nn_chunkref_cp (&dst->sphdr, &src->sphdr); nn_chunkref_cp (&dst->hdrs, &src->hdrs); nn_chunkref_cp (&dst->body, &src->body); } void nn_msg_bulkcopy_start (struct nn_msg *self, uint32_t copies) { nn_chunkref_bulkcopy_start (&self->sphdr, copies); nn_chunkref_bulkcopy_start (&self->hdrs, copies); nn_chunkref_bulkcopy_start (&self->body, copies); } void nn_msg_bulkcopy_cp (struct nn_msg *dst, struct nn_msg *src) { nn_chunkref_bulkcopy_cp (&dst->sphdr, &src->sphdr); nn_chunkref_bulkcopy_cp (&dst->hdrs, &src->hdrs); nn_chunkref_bulkcopy_cp (&dst->body, &src->body); } void nn_msg_replace_body (struct nn_msg *self, struct nn_chunkref new_body) { nn_chunkref_term (&self->body); self->body = new_body; } nanomsg-0.8-beta/src/utils/mutex.h0000664000175000017500000000342012623652600020103 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef NN_MUTEX_INCLUDED #define NN_MUTEX_INCLUDED #ifdef NN_HAVE_WINDOWS #include "win.h" #else #include #endif struct nn_mutex { #ifdef NN_HAVE_WINDOWS CRITICAL_SECTION mutex; #else pthread_mutex_t mutex; #endif }; /* Initialise the mutex. */ void nn_mutex_init (struct nn_mutex *self); /* Terminate the mutex. */ void nn_mutex_term (struct nn_mutex *self); /* Lock the mutex. Behaviour of multiple locks from the same thread is undefined. */ void nn_mutex_lock (struct nn_mutex *self); /* Unlock the mutex. Behaviour of unlocking an unlocked mutex is undefined */ void nn_mutex_unlock (struct nn_mutex *self); #endif nanomsg-0.8-beta/src/utils/mutex.c0000664000175000017500000000415412623652600020103 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "mutex.h" #include "err.h" #ifdef NN_HAVE_WINDOWS void nn_mutex_init (struct nn_mutex *self) { InitializeCriticalSection (&self->mutex); } void nn_mutex_term (struct nn_mutex *self) { DeleteCriticalSection (&self->mutex); } void nn_mutex_lock (struct nn_mutex *self) { EnterCriticalSection (&self->mutex); } void nn_mutex_unlock (struct nn_mutex *self) { LeaveCriticalSection (&self->mutex); } #else void nn_mutex_init (struct nn_mutex *self) { int rc; rc = pthread_mutex_init (&self->mutex, NULL); errnum_assert (rc == 0, rc); } void nn_mutex_term (struct nn_mutex *self) { int rc; rc = pthread_mutex_destroy (&self->mutex); errnum_assert (rc == 0, rc); } void nn_mutex_lock (struct nn_mutex *self) { int rc; rc = pthread_mutex_lock (&self->mutex); errnum_assert (rc == 0, rc); } void nn_mutex_unlock (struct nn_mutex *self) { int rc; rc = pthread_mutex_unlock (&self->mutex); errnum_assert (rc == 0, rc); } #endif nanomsg-0.8-beta/src/utils/queue.h0000664000175000017500000000531512623652600020072 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik 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. */ #ifndef NN_QUEUE_INCLUDED #define NN_QUEUE_INCLUDED /* Undefined value for initialising a queue item which is not part of a queue. */ #define NN_QUEUE_NOTINQUEUE ((struct nn_queue_item*) -1) /* Use for initialising a queue item statically. */ #define NN_QUEUE_ITEM_INITIALIZER {NN_LIST_NOTINQUEUE} struct nn_queue_item { struct nn_queue_item *next; }; struct nn_queue { struct nn_queue_item *head; struct nn_queue_item *tail; }; /* Initialise the queue. */ void nn_queue_init (struct nn_queue *self); /* Terminate the queue. Note that queue must be manually emptied before the termination. */ void nn_queue_term (struct nn_queue *self); /* Returns 1 if there are no items in the queue, 0 otherwise. */ int nn_queue_empty (struct nn_queue *self); /* Inserts one element into the queue. */ void nn_queue_push (struct nn_queue *self, struct nn_queue_item *item); /* Remove the item if it is present in the queue. */ void nn_queue_remove (struct nn_queue *self, struct nn_queue_item *item); /* Retrieves one element from the queue. The element is removed from the queue. Returns NULL if the queue is empty. */ struct nn_queue_item *nn_queue_pop (struct nn_queue *self); /* Initialise a queue item. At this point it is not a part of any queue. */ void nn_queue_item_init (struct nn_queue_item *self); /* Terminate a queue item. The item must not be in a queue prior to this call. */ void nn_queue_item_term (struct nn_queue_item *self); /* Returns 1 if item is a part of a queue. 0 otherwise. */ int nn_queue_item_isinqueue (struct nn_queue_item *self); #endif nanomsg-0.8-beta/src/utils/queue.c0000664000175000017500000000564312623652600020071 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 #include "queue.h" #include "err.h" void nn_queue_init (struct nn_queue *self) { self->head = NULL; self->tail = NULL; } void nn_queue_term (struct nn_queue *self) { self->head = NULL; self->tail = NULL; } int nn_queue_empty (struct nn_queue *self) { return self->head ? 0 : 1; } void nn_queue_push (struct nn_queue *self, struct nn_queue_item *item) { nn_assert (item->next == NN_QUEUE_NOTINQUEUE); item->next = NULL; if (!self->head) self->head = item; if (self->tail) self->tail->next = item; self->tail = item; } void nn_queue_remove (struct nn_queue *self, struct nn_queue_item *item) { struct nn_queue_item *it; struct nn_queue_item *prev; if (item->next == NN_QUEUE_NOTINQUEUE) return; prev = NULL; for (it = self->head; it != NULL; it = it->next) { if (it == item) { if (self->head == it) self->head = it->next; if (self->tail == it) self->tail = prev; if (prev) prev->next = it->next; item->next = NN_QUEUE_NOTINQUEUE; return; } prev = it; } } struct nn_queue_item *nn_queue_pop (struct nn_queue *self) { struct nn_queue_item *result; if (!self->head) return NULL; result = self->head; self->head = result->next; if (!self->head) self->tail = NULL; result->next = NN_QUEUE_NOTINQUEUE; return result; } void nn_queue_item_init (struct nn_queue_item *self) { self->next = NN_QUEUE_NOTINQUEUE; } void nn_queue_item_term (struct nn_queue_item *self) { nn_assert (self->next == NN_QUEUE_NOTINQUEUE); } int nn_queue_item_isinqueue (struct nn_queue_item *self) { return self->next == NN_QUEUE_NOTINQUEUE ? 0 : 1; } nanomsg-0.8-beta/src/utils/random.h0000664000175000017500000000257312623652600020231 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef NN_RANDOM_INCLUDED #define NN_RANDOM_INCLUDED #include /* Seeds the pseudorandom number generator. */ void nn_random_seed (); /* Generate a pseudorandom byte sequence. */ void nn_random_generate (void *buf, size_t len); #endif nanomsg-0.8-beta/src/utils/random.c0000664000175000017500000000423412623652600020220 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "random.h" #include "clock.h" #include "fast.h" #ifdef NN_HAVE_WINDOWS #include "win.h" #else #include #include #endif #include static uint64_t nn_random_state; void nn_random_seed () { uint64_t pid; #ifdef NN_HAVE_WINDOWS pid = (uint64_t) GetCurrentProcessId (); #else pid = (uint64_t) getpid (); #endif /* The initial state for pseudo-random number generator is computed from the exact timestamp and process ID. */ memcpy (&nn_random_state, "\xfa\x9b\x23\xe3\x07\xcc\x61\x1f", 8); nn_random_state ^= pid + nn_clock_timestamp (); } void nn_random_generate (void *buf, size_t len) { uint8_t *pos; pos = (uint8_t*) buf; while (1) { /* Generate a pseudo-random integer. */ nn_random_state = nn_random_state * 1103515245 + 12345; /* Move the bytes to the output buffer. */ memcpy (pos, &nn_random_state, len > 8 ? 8 : len); if (nn_fast (len <= 8)) return; len -= 8; pos += 8; } } nanomsg-0.8-beta/src/utils/sem.h0000664000175000017500000000367312623652600017537 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef NN_SEM_INCLUDED #define NN_SEM_INCLUDED /* Simple semaphore. It can have only two values (0/1 i.e. locked/unlocked). */ struct nn_sem; /* Initialise the sem object. It is created in locked state. */ void nn_sem_init (struct nn_sem *self); /* Uninitialise the sem object. */ void nn_sem_term (struct nn_sem *self); /* Unlock the semaphore. */ void nn_sem_post (struct nn_sem *self); /* Waits till sem object becomes unlocked and locks it. */ int nn_sem_wait (struct nn_sem *self); #if defined NN_HAVE_OSX #include struct nn_sem { pthread_mutex_t mutex; pthread_cond_t cond; int signaled; }; #elif defined NN_HAVE_WINDOWS #include "win.h" struct nn_sem { HANDLE h; }; #elif defined NN_HAVE_SEMAPHORE #include struct nn_sem { sem_t sem; }; #endif #endif nanomsg-0.8-beta/src/utils/sem.c0000664000175000017500000001017712623652600017527 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "sem.h" #include "err.h" #include "fast.h" #if defined NN_HAVE_OSX void nn_sem_init (struct nn_sem *self) { int rc; rc = pthread_mutex_init (&self->mutex, NULL); errnum_assert (rc == 0, rc); rc = pthread_cond_init (&self->cond, NULL); errnum_assert (rc == 0, rc); self->signaled = 0; } void nn_sem_term (struct nn_sem *self) { int rc; rc = pthread_cond_destroy (&self->cond); errnum_assert (rc == 0, rc); rc = pthread_mutex_destroy (&self->mutex); errnum_assert (rc == 0, rc); } void nn_sem_post (struct nn_sem *self) { int rc; rc = pthread_mutex_lock (&self->mutex); errnum_assert (rc == 0, rc); nn_assert (self->signaled == 0); self->signaled = 1; rc = pthread_cond_signal (&self->cond); errnum_assert (rc == 0, rc); rc = pthread_mutex_unlock (&self->mutex); errnum_assert (rc == 0, rc); } int nn_sem_wait (struct nn_sem *self) { int rc; /* With OSX, semaphores are global named objects. They are not useful for our use case. To get a similar object we exploit the implementation detail of pthread_cond_wait() in Darwin kernel: It exits if signal is caught. Note that this behaviour is not mandated by POSIX and may break with future versions of Darwin. */ rc = pthread_mutex_lock (&self->mutex); errnum_assert (rc == 0, rc); if (nn_fast (self->signaled)) { rc = pthread_mutex_unlock (&self->mutex); errnum_assert (rc == 0, rc); return 0; } rc = pthread_cond_wait (&self->cond, &self->mutex); errnum_assert (rc == 0, rc); if (nn_slow (!self->signaled)) { rc = pthread_mutex_unlock (&self->mutex); errnum_assert (rc == 0, rc); return -EINTR; } self->signaled = 0; rc = pthread_mutex_unlock (&self->mutex); errnum_assert (rc == 0, rc); return 0; } #elif defined NN_HAVE_WINDOWS void nn_sem_init (struct nn_sem *self) { self->h = CreateEvent (NULL, FALSE, FALSE, NULL); win_assert (self->h); } void nn_sem_term (struct nn_sem *self) { BOOL brc; brc = CloseHandle (self->h); win_assert (brc); } void nn_sem_post (struct nn_sem *self) { BOOL brc; brc = SetEvent (self->h); win_assert (brc); } int nn_sem_wait (struct nn_sem *self) { DWORD rc; rc = WaitForSingleObject (self->h, INFINITE); win_assert (rc != WAIT_FAILED); nn_assert (rc == WAIT_OBJECT_0); return 0; } #elif defined NN_HAVE_SEMAPHORE void nn_sem_init (struct nn_sem *self) { int rc; rc = sem_init (&self->sem, 0, 0); errno_assert (rc == 0); } void nn_sem_term (struct nn_sem *self) { int rc; rc = sem_destroy (&self->sem); errno_assert (rc == 0); } void nn_sem_post (struct nn_sem *self) { int rc; rc = sem_post (&self->sem); errno_assert (rc == 0); } int nn_sem_wait (struct nn_sem *self) { int rc; rc = sem_wait (&self->sem); if (nn_slow (rc < 0 && errno == EINTR)) return -EINTR; errno_assert (rc == 0); return 0; } #else #error #endif nanomsg-0.8-beta/src/utils/sleep.h0000664000175000017500000000242712623652600020057 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef NN_SLEEP_INCLUDED #define NN_SLEEP_INCLUDED /* Platform independent implementation of sleeping. */ void nn_sleep (int milliseconds); #endif nanomsg-0.8-beta/src/utils/sleep.c0000664000175000017500000000301712623652600020046 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "sleep.h" #include "err.h" #ifdef NN_HAVE_WINDOWS #include "win.h" void nn_sleep (int milliseconds) { Sleep (milliseconds); } #else #include void nn_sleep (int milliseconds) { int rc; struct timespec ts; ts.tv_sec = milliseconds / 1000; ts.tv_nsec = milliseconds % 1000 * 1000000; rc = nanosleep (&ts, NULL); errno_assert (rc == 0); } #endif nanomsg-0.8-beta/src/utils/stopwatch.h0000664000175000017500000000411012623652600020752 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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. */ #ifndef NN_STOPWATCH_INCLUDED #define NN_STOPWATCH_INCLUDED #include "err.h" #include "int.h" /* Check whether measured time is the expected time (in microseconds). The upper tolerance is 50ms so that the test doesn't fail even on very slow or very loaded systems. Likewise on some systems we can wind up firing up to a single tick early (Windows), so the lower bound is pretty low. The consequence of this is that programs which specify a timeout should be a little more pessimistic (at least 10ms) then they might otherwise think they need to be. */ #define time_assert(actual,expected) \ nn_assert (actual > ((expected) - 10000) && actual < ((expected) + 50000)); /* Measures time interval in microseconds. */ struct nn_stopwatch { uint64_t start; }; void nn_stopwatch_init (struct nn_stopwatch *self); uint64_t nn_stopwatch_term (struct nn_stopwatch *self); #endif nanomsg-0.8-beta/src/utils/stopwatch.c0000664000175000017500000000426012623652600020753 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "stopwatch.h" #if defined NN_HAVE_WINDOWS #include "win.h" void nn_stopwatch_init (struct nn_stopwatch *self) { LARGE_INTEGER time; QueryPerformanceCounter (&time); self->start = (uint64_t) (time.QuadPart); } uint64_t nn_stopwatch_term (struct nn_stopwatch *self) { LARGE_INTEGER tps; LARGE_INTEGER time; QueryPerformanceFrequency (&tps); QueryPerformanceCounter (&time); return (uint64_t) ((time.QuadPart - self->start) * 1000000 / tps.QuadPart); } #else #include #include #include void nn_stopwatch_init (struct nn_stopwatch *self) { int rc; struct timeval tv; rc = gettimeofday (&tv, NULL); assert (rc == 0); self->start = (uint64_t) (((uint64_t) tv.tv_sec) * 1000000 + tv.tv_usec); } uint64_t nn_stopwatch_term (struct nn_stopwatch *self) { int rc; struct timeval tv; uint64_t end; rc = gettimeofday (&tv, NULL); assert (rc == 0); end = (uint64_t) (((uint64_t) tv.tv_sec) * 1000000 + tv.tv_usec); return end - self->start; } #endif nanomsg-0.8-beta/src/utils/thread.h0000664000175000017500000000301412623652600020207 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_THREAD_INCLUDED #define NN_THREAD_INCLUDED /* Platform independent implementation of threading. */ typedef void (nn_thread_routine) (void*); #if defined NN_HAVE_WINDOWS #include "thread_win.h" #else #include "thread_posix.h" #endif void nn_thread_init (struct nn_thread *self, nn_thread_routine *routine, void *arg); void nn_thread_term (struct nn_thread *self); #endif nanomsg-0.8-beta/src/utils/thread.c0000664000175000017500000000236312623652600020210 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "thread.h" #ifdef NN_HAVE_WINDOWS #include "thread_win.inc" #else #include "thread_posix.inc" #endif nanomsg-0.8-beta/src/utils/thread_posix.h0000664000175000017500000000236012623652600021434 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 struct nn_thread { nn_thread_routine *routine; void *arg; pthread_t handle; }; nanomsg-0.8-beta/src/utils/thread_posix.inc0000664000175000017500000000461012623652600021756 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik All rights reserved. Copyright (c) 2014 Achille Roussel 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 "err.h" #include static void *nn_thread_main_routine (void *arg) { struct nn_thread *self; self = (struct nn_thread*) arg; /* Run the thread routine. */ self->routine (self->arg); return NULL; } void nn_thread_init (struct nn_thread *self, nn_thread_routine *routine, void *arg) { int rc; sigset_t new_sigmask; sigset_t old_sigmask; /* No signals should be processed by this thread. The library doesn't use signals and thus all the signals should be delivered to application threads, not to worker threads. */ rc = sigfillset (&new_sigmask); errno_assert (rc == 0); rc = pthread_sigmask (SIG_BLOCK, &new_sigmask, &old_sigmask); errnum_assert (rc == 0, rc); self->routine = routine; self->arg = arg; rc = pthread_create (&self->handle, NULL, nn_thread_main_routine, (void*) self); errnum_assert (rc == 0, rc); /* Restore signal set to what it was before. */ rc = pthread_sigmask (SIG_SETMASK, &old_sigmask, NULL); errnum_assert (rc == 0, rc); } void nn_thread_term (struct nn_thread *self) { int rc; rc = pthread_join (self->handle, NULL); errnum_assert (rc == 0, rc); } nanomsg-0.8-beta/src/utils/thread_win.h0000664000175000017500000000235112623652600021067 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "win.h" struct nn_thread { nn_thread_routine *routine; void *arg; HANDLE handle; }; nanomsg-0.8-beta/src/utils/thread_win.inc0000664000175000017500000000352312623652600021413 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "err.h" static unsigned int __stdcall nn_thread_main_routine (void *arg) { struct nn_thread *self; self = (struct nn_thread*) arg; self->routine (self->arg); return 0; } void nn_thread_init (struct nn_thread *self, nn_thread_routine *routine, void *arg) { self->routine = routine; self->arg = arg; self->handle = (HANDLE) _beginthreadex (NULL, 0, nn_thread_main_routine, (void*) self, 0 , NULL); win_assert (self->handle != NULL); } void nn_thread_term (struct nn_thread *self) { DWORD rc; BOOL brc; rc = WaitForSingleObject (self->handle, INFINITE); win_assert (rc != WAIT_FAILED); brc = CloseHandle (self->handle); win_assert (brc != 0); } nanomsg-0.8-beta/src/utils/win.h0000664000175000017500000000307612623652600017545 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef NN_WIN_INCLUDED #define NN_WIN_INCLUDED #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #include #include #include #include /* This structure does not exist on Windows platform. Let's fake it. */ struct sockaddr_un { short sun_family; char sun_path [sizeof (struct sockaddr_storage) - sizeof (short)]; }; #define ssize_t int #endif nanomsg-0.8-beta/src/utils/wire.h0000664000175000017500000000271212623652600017712 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_WIRE_INCLUDED #define NN_WIRE_INCLUDED #include "int.h" uint16_t nn_gets (const uint8_t *buf); void nn_puts (uint8_t *buf, uint16_t val); uint32_t nn_getl (const uint8_t *buf); void nn_putl (uint8_t *buf, uint32_t val); uint64_t nn_getll (const uint8_t *buf); void nn_putll (uint8_t *buf, uint64_t val); #endif nanomsg-0.8-beta/src/utils/wire.c0000664000175000017500000000523712623652600017712 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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 "wire.h" #if defined NN_HAVE_WINDOWS #include "win.h" #else #include #endif uint16_t nn_gets (const uint8_t *buf) { return (((uint16_t) buf [0]) << 8) | ((uint16_t) buf [1]); } void nn_puts (uint8_t *buf, uint16_t val) { buf [0] = (uint8_t) (((val) >> 8) & 0xff); buf [1] = (uint8_t) (val & 0xff); } uint32_t nn_getl (const uint8_t *buf) { return (((uint32_t) buf [0]) << 24) | (((uint32_t) buf [1]) << 16) | (((uint32_t) buf [2]) << 8) | ((uint32_t) buf [3]); } void nn_putl (uint8_t *buf, uint32_t val) { buf [0] = (uint8_t) (((val) >> 24) & 0xff); buf [1] = (uint8_t) (((val) >> 16) & 0xff); buf [2] = (uint8_t) (((val) >> 8) & 0xff); buf [3] = (uint8_t) (val & 0xff); } uint64_t nn_getll (const uint8_t *buf) { return (((uint64_t) buf [0]) << 56) | (((uint64_t) buf [1]) << 48) | (((uint64_t) buf [2]) << 40) | (((uint64_t) buf [3]) << 32) | (((uint64_t) buf [4]) << 24) | (((uint64_t) buf [5]) << 16) | (((uint64_t) buf [6]) << 8) | (((uint64_t) buf [7] << 0)); } void nn_putll (uint8_t *buf, uint64_t val) { buf [0] = (uint8_t) ((val >> 56) & 0xff); buf [1] = (uint8_t) ((val >> 48) & 0xff); buf [2] = (uint8_t) ((val >> 40) & 0xff); buf [3] = (uint8_t) ((val >> 32) & 0xff); buf [4] = (uint8_t) ((val >> 24) & 0xff); buf [5] = (uint8_t) ((val >> 16) & 0xff); buf [6] = (uint8_t) ((val >> 8) & 0xff); buf [7] = (uint8_t) (val & 0xff); } nanomsg-0.8-beta/src/nn.h0000664000175000017500000003054712623652600016226 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. All rights reserved. Copyright 2015 Garrett D'Amore 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. */ #ifndef NN_H_INCLUDED #define NN_H_INCLUDED #ifdef __cplusplus extern "C" { #endif #include #include /* Handle DSO symbol visibility */ #if defined NN_NO_EXPORTS # define NN_EXPORT #else # if defined _WIN32 # if defined NN_EXPORTS # define NN_EXPORT __declspec(dllexport) # else # define NN_EXPORT __declspec(dllimport) # endif # else # if defined __SUNPRO_C # define NN_EXPORT __global # elif (defined __GNUC__ && __GNUC__ >= 4) || \ defined __INTEL_COMPILER || defined __clang__ # define NN_EXPORT __attribute__ ((visibility("default"))) # else # define NN_EXPORT # endif # endif #endif /******************************************************************************/ /* ABI versioning support. */ /******************************************************************************/ /* Don't change this unless you know exactly what you're doing and have */ /* read and understand the following documents: */ /* www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html */ /* www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html */ /* The current interface version. */ #define NN_VERSION_CURRENT 4 /* The latest revision of the current interface. */ #define NN_VERSION_REVISION 0 /* How many past interface versions are still supported. */ #define NN_VERSION_AGE 0 /******************************************************************************/ /* Errors. */ /******************************************************************************/ /* A number random enough not to collide with different errno ranges on */ /* different OSes. The assumption is that error_t is at least 32-bit type. */ #define NN_HAUSNUMERO 156384712 /* On some platforms some standard POSIX errnos are not defined. */ #ifndef ENOTSUP #define ENOTSUP (NN_HAUSNUMERO + 1) #endif #ifndef EPROTONOSUPPORT #define EPROTONOSUPPORT (NN_HAUSNUMERO + 2) #endif #ifndef ENOBUFS #define ENOBUFS (NN_HAUSNUMERO + 3) #endif #ifndef ENETDOWN #define ENETDOWN (NN_HAUSNUMERO + 4) #endif #ifndef EADDRINUSE #define EADDRINUSE (NN_HAUSNUMERO + 5) #endif #ifndef EADDRNOTAVAIL #define EADDRNOTAVAIL (NN_HAUSNUMERO + 6) #endif #ifndef ECONNREFUSED #define ECONNREFUSED (NN_HAUSNUMERO + 7) #endif #ifndef EINPROGRESS #define EINPROGRESS (NN_HAUSNUMERO + 8) #endif #ifndef ENOTSOCK #define ENOTSOCK (NN_HAUSNUMERO + 9) #endif #ifndef EAFNOSUPPORT #define EAFNOSUPPORT (NN_HAUSNUMERO + 10) #endif #ifndef EPROTO #define EPROTO (NN_HAUSNUMERO + 11) #endif #ifndef EAGAIN #define EAGAIN (NN_HAUSNUMERO + 12) #endif #ifndef EBADF #define EBADF (NN_HAUSNUMERO + 13) #endif #ifndef EINVAL #define EINVAL (NN_HAUSNUMERO + 14) #endif #ifndef EMFILE #define EMFILE (NN_HAUSNUMERO + 15) #endif #ifndef EFAULT #define EFAULT (NN_HAUSNUMERO + 16) #endif #ifndef EACCES #define EACCES (NN_HAUSNUMERO + 17) #endif #ifndef EACCESS #define EACCESS (EACCES) #endif #ifndef ENETRESET #define ENETRESET (NN_HAUSNUMERO + 18) #endif #ifndef ENETUNREACH #define ENETUNREACH (NN_HAUSNUMERO + 19) #endif #ifndef EHOSTUNREACH #define EHOSTUNREACH (NN_HAUSNUMERO + 20) #endif #ifndef ENOTCONN #define ENOTCONN (NN_HAUSNUMERO + 21) #endif #ifndef EMSGSIZE #define EMSGSIZE (NN_HAUSNUMERO + 22) #endif #ifndef ETIMEDOUT #define ETIMEDOUT (NN_HAUSNUMERO + 23) #endif #ifndef ECONNABORTED #define ECONNABORTED (NN_HAUSNUMERO + 24) #endif #ifndef ECONNRESET #define ECONNRESET (NN_HAUSNUMERO + 25) #endif #ifndef ENOPROTOOPT #define ENOPROTOOPT (NN_HAUSNUMERO + 26) #endif #ifndef EISCONN #define EISCONN (NN_HAUSNUMERO + 27) #define NN_EISCONN_DEFINED #endif #ifndef ESOCKTNOSUPPORT #define ESOCKTNOSUPPORT (NN_HAUSNUMERO + 28) #endif /* Native nanomsg error codes. */ #ifndef ETERM #define ETERM (NN_HAUSNUMERO + 53) #endif #ifndef EFSM #define EFSM (NN_HAUSNUMERO + 54) #endif /* This function retrieves the errno as it is known to the library. */ /* The goal of this function is to make the code 100% portable, including */ /* where the library is compiled with certain CRT library (on Windows) and */ /* linked to an application that uses different CRT library. */ NN_EXPORT int nn_errno (void); /* Resolves system errors and native errors to human-readable string. */ NN_EXPORT const char *nn_strerror (int errnum); /* Returns the symbol name (e.g. "NN_REQ") and value at a specified index. */ /* If the index is out-of-range, returns NULL and sets errno to EINVAL */ /* General usage is to start at i=0 and iterate until NULL is returned. */ NN_EXPORT const char *nn_symbol (int i, int *value); /* Constants that are returned in `ns` member of nn_symbol_properties */ #define NN_NS_NAMESPACE 0 #define NN_NS_VERSION 1 #define NN_NS_DOMAIN 2 #define NN_NS_TRANSPORT 3 #define NN_NS_PROTOCOL 4 #define NN_NS_OPTION_LEVEL 5 #define NN_NS_SOCKET_OPTION 6 #define NN_NS_TRANSPORT_OPTION 7 #define NN_NS_OPTION_TYPE 8 #define NN_NS_OPTION_UNIT 9 #define NN_NS_FLAG 10 #define NN_NS_ERROR 11 #define NN_NS_LIMIT 12 #define NN_NS_EVENT 13 /* Constants that are returned in `type` member of nn_symbol_properties */ #define NN_TYPE_NONE 0 #define NN_TYPE_INT 1 #define NN_TYPE_STR 2 /* Constants that are returned in the `unit` member of nn_symbol_properties */ #define NN_UNIT_NONE 0 #define NN_UNIT_BYTES 1 #define NN_UNIT_MILLISECONDS 2 #define NN_UNIT_PRIORITY 3 #define NN_UNIT_BOOLEAN 4 /* Structure that is returned from nn_symbol */ struct nn_symbol_properties { /* The constant value */ int value; /* The constant name */ const char* name; /* The constant namespace, or zero for namespaces themselves */ int ns; /* The option type for socket option constants */ int type; /* The unit for the option value for socket option constants */ int unit; }; /* Fills in nn_symbol_properties structure and returns it's length */ /* If the index is out-of-range, returns 0 */ /* General usage is to start at i=0 and iterate until zero is returned. */ NN_EXPORT int nn_symbol_info (int i, struct nn_symbol_properties *buf, int buflen); /******************************************************************************/ /* Helper function for shutting down multi-threaded applications. */ /******************************************************************************/ NN_EXPORT void nn_term (void); /******************************************************************************/ /* Zero-copy support. */ /******************************************************************************/ #define NN_MSG ((size_t) -1) NN_EXPORT void *nn_allocmsg (size_t size, int type); NN_EXPORT void *nn_reallocmsg (void *msg, size_t size); NN_EXPORT int nn_freemsg (void *msg); /******************************************************************************/ /* Socket definition. */ /******************************************************************************/ struct nn_iovec { void *iov_base; size_t iov_len; }; struct nn_msghdr { struct nn_iovec *msg_iov; int msg_iovlen; void *msg_control; size_t msg_controllen; }; struct nn_cmsghdr { size_t cmsg_len; int cmsg_level; int cmsg_type; }; /* Internal stuff. Not to be used directly. */ NN_EXPORT struct nn_cmsghdr *nn_cmsg_nxthdr_ ( const struct nn_msghdr *mhdr, const struct nn_cmsghdr *cmsg); #define NN_CMSG_ALIGN_(len) \ (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) /* POSIX-defined msghdr manipulation. */ #define NN_CMSG_FIRSTHDR(mhdr) \ nn_cmsg_nxthdr_ ((struct nn_msghdr*) (mhdr), NULL) #define NN_CMSG_NXTHDR(mhdr, cmsg) \ nn_cmsg_nxthdr_ ((struct nn_msghdr*) (mhdr), (struct nn_cmsghdr*) (cmsg)) #define NN_CMSG_DATA(cmsg) \ ((unsigned char*) (((struct nn_cmsghdr*) (cmsg)) + 1)) /* Extensions to POSIX defined by RFC 3542. */ #define NN_CMSG_SPACE(len) \ (NN_CMSG_ALIGN_ (len) + NN_CMSG_ALIGN_ (sizeof (struct nn_cmsghdr))) #define NN_CMSG_LEN(len) \ (NN_CMSG_ALIGN_ (sizeof (struct nn_cmsghdr)) + (len)) /* SP address families. */ #define AF_SP 1 #define AF_SP_RAW 2 /* Max size of an SP address. */ #define NN_SOCKADDR_MAX 128 /* Socket option levels: Negative numbers are reserved for transports, positive for socket types. */ #define NN_SOL_SOCKET 0 /* Generic socket options (NN_SOL_SOCKET level). */ #define NN_LINGER 1 #define NN_SNDBUF 2 #define NN_RCVBUF 3 #define NN_SNDTIMEO 4 #define NN_RCVTIMEO 5 #define NN_RECONNECT_IVL 6 #define NN_RECONNECT_IVL_MAX 7 #define NN_SNDPRIO 8 #define NN_RCVPRIO 9 #define NN_SNDFD 10 #define NN_RCVFD 11 #define NN_DOMAIN 12 #define NN_PROTOCOL 13 #define NN_IPV4ONLY 14 #define NN_SOCKET_NAME 15 #define NN_RCVMAXSIZE 16 /* Send/recv options. */ #define NN_DONTWAIT 1 /* Ancillary data. */ #define PROTO_SP 1 #define SP_HDR 1 NN_EXPORT int nn_socket (int domain, int protocol); NN_EXPORT int nn_close (int s); NN_EXPORT int nn_setsockopt (int s, int level, int option, const void *optval, size_t optvallen); NN_EXPORT int nn_getsockopt (int s, int level, int option, void *optval, size_t *optvallen); NN_EXPORT int nn_bind (int s, const char *addr); NN_EXPORT int nn_connect (int s, const char *addr); NN_EXPORT int nn_shutdown (int s, int how); NN_EXPORT int nn_send (int s, const void *buf, size_t len, int flags); NN_EXPORT int nn_recv (int s, void *buf, size_t len, int flags); NN_EXPORT int nn_sendmsg (int s, const struct nn_msghdr *msghdr, int flags); NN_EXPORT int nn_recvmsg (int s, struct nn_msghdr *msghdr, int flags); /******************************************************************************/ /* Socket mutliplexing support. */ /******************************************************************************/ #define NN_POLLIN 1 #define NN_POLLOUT 2 struct nn_pollfd { int fd; short events; short revents; }; NN_EXPORT int nn_poll (struct nn_pollfd *fds, int nfds, int timeout); /******************************************************************************/ /* Built-in support for devices. */ /******************************************************************************/ NN_EXPORT int nn_device (int s1, int s2); /******************************************************************************/ /* Built-in support for multiplexers. */ /******************************************************************************/ NN_EXPORT int nn_tcpmuxd (int port); #ifdef __cplusplus } #endif #endif nanomsg-0.8-beta/src/inproc.h0000664000175000017500000000242712623652600017101 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef INPROC_H_INCLUDED #define INPROC_H_INCLUDED #ifdef __cplusplus extern "C" { #endif #define NN_INPROC -1 #ifdef __cplusplus } #endif #endif nanomsg-0.8-beta/src/ipc.h0000664000175000017500000000241612623652600016360 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef IPC_H_INCLUDED #define IPC_H_INCLUDED #ifdef __cplusplus extern "C" { #endif #define NN_IPC -2 #ifdef __cplusplus } #endif #endif nanomsg-0.8-beta/src/tcp.h0000664000175000017500000000245012623652600016371 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef TCP_H_INCLUDED #define TCP_H_INCLUDED #ifdef __cplusplus extern "C" { #endif #define NN_TCP -3 #define NN_TCP_NODELAY 1 #ifdef __cplusplus } #endif #endif nanomsg-0.8-beta/src/ws.h0000664000175000017500000000337612623652600016244 0ustar00travistravis00000000000000/* Copyright (c) 2012 250bpm s.r.o. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. All rights reserved. Copyright 2015 Garrett D'Amore 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. */ #ifndef WS_H_INCLUDED #define WS_H_INCLUDED #include "nn.h" #ifdef __cplusplus extern "C" { #endif #define NN_WS -4 /* NN_WS level socket/cmsg options. Note that only NN_WSMG_TYPE_TEXT and NN_WS_MSG_TYPE_BINARY messages are supported fully by this implementation. Attempting to set other message types is undefined. */ #define NN_WS_MSG_TYPE 1 /* WebSocket opcode constants as per RFC 6455 5.2 */ #define NN_WS_MSG_TYPE_TEXT 0x01 #define NN_WS_MSG_TYPE_BINARY 0x02 #ifdef __cplusplus } #endif #endif nanomsg-0.8-beta/src/pair.h0000664000175000017500000000250012623652600016532 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef PAIR_H_INCLUDED #define PAIR_H_INCLUDED #ifdef __cplusplus extern "C" { #endif #define NN_PROTO_PAIR 1 #define NN_PAIR (NN_PROTO_PAIR * 16 + 0) #ifdef __cplusplus } #endif #endif nanomsg-0.8-beta/src/pubsub.h0000664000175000017500000000265212623652600017107 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef PUBSUB_H_INCLUDED #define PUBSUB_H_INCLUDED #ifdef __cplusplus extern "C" { #endif #define NN_PROTO_PUBSUB 2 #define NN_PUB (NN_PROTO_PUBSUB * 16 + 0) #define NN_SUB (NN_PROTO_PUBSUB * 16 + 1) #define NN_SUB_SUBSCRIBE 1 #define NN_SUB_UNSUBSCRIBE 2 #ifdef __cplusplus } #endif #endif nanomsg-0.8-beta/src/reqrep.h0000664000175000017500000000324312623652600017102 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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. */ #ifndef REQREP_H_INCLUDED #define REQREP_H_INCLUDED #include "nn.h" #ifdef __cplusplus extern "C" { #endif #define NN_PROTO_REQREP 3 #define NN_REQ (NN_PROTO_REQREP * 16 + 0) #define NN_REP (NN_PROTO_REQREP * 16 + 1) #define NN_REQ_RESEND_IVL 1 typedef union nn_req_handle { int i; void *ptr; } nn_req_handle; NN_EXPORT int nn_req_send (int s, nn_req_handle hndl, const void *buf, size_t len, int flags); NN_EXPORT int nn_req_recv (int s, nn_req_handle *hndl, void *buf, size_t len, int flags); #ifdef __cplusplus } #endif #endif nanomsg-0.8-beta/src/pipeline.h0000664000175000017500000000267212623652600017416 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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. */ #ifndef PIPELINE_H_INCLUDED #define PIPELINE_H_INCLUDED #ifdef __cplusplus extern "C" { #endif #define NN_PROTO_PIPELINE 5 #define NN_PUSH (NN_PROTO_PIPELINE * 16 + 0) #define NN_PULL (NN_PROTO_PIPELINE * 16 + 1) #ifdef __cplusplus } #endif #endif nanomsg-0.8-beta/src/survey.h0000664000175000017500000000311612623652600017140 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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. */ #ifndef SURVEY_H_INCLUDED #define SURVEY_H_INCLUDED #ifdef __cplusplus extern "C" { #endif #define NN_PROTO_SURVEY 6 /* NB: Version 0 used 16 + 0/1. That version lacked backtraces, and so is wire-incompatible with this version. */ #define NN_SURVEYOR (NN_PROTO_SURVEY * 16 + 2) #define NN_RESPONDENT (NN_PROTO_SURVEY * 16 + 3) #define NN_SURVEYOR_DEADLINE 1 #ifdef __cplusplus } #endif #endif nanomsg-0.8-beta/src/bus.h0000664000175000017500000000247312623652600016401 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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. */ #ifndef BUS_H_INCLUDED #define BUS_H_INCLUDED #ifdef __cplusplus extern "C" { #endif #define NN_PROTO_BUS 7 #define NN_BUS (NN_PROTO_BUS * 16 + 0) #ifdef __cplusplus } #endif #endif nanomsg-0.8-beta/src/tcpmux.h0000664000175000017500000000246412623652600017130 0ustar00travistravis00000000000000/* Copyright (c) 2014 Martin Sustrik 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. */ #ifndef TCPMUX_H_INCLUDED #define TCPMUX_H_INCLUDED #ifdef __cplusplus extern "C" { #endif #define NN_TCPMUX -5 #define NN_TCPMUX_NODELAY 1 #ifdef __cplusplus } #endif #endif nanomsg-0.8-beta/src/transport.h0000664000175000017500000002311012623652600017633 0ustar00travistravis00000000000000/* Copyright (c) 2012-2014 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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. */ #ifndef NN_TRANSPORT_INCLUDED #define NN_TRANSPORT_INCLUDED #include "nn.h" #include "aio/fsm.h" #include "utils/list.h" #include "utils/msg.h" #include "utils/int.h" #include /* This is the API between the nanomsg core and individual transports. */ struct nn_sock; struct nn_cp; /******************************************************************************/ /* Container for transport-specific socket options. */ /******************************************************************************/ struct nn_optset; struct nn_optset_vfptr { void (*destroy) (struct nn_optset *self); int (*setopt) (struct nn_optset *self, int option, const void *optval, size_t optvallen); int (*getopt) (struct nn_optset *self, int option, void *optval, size_t *optvallen); }; struct nn_optset { const struct nn_optset_vfptr *vfptr; }; /******************************************************************************/ /* The base class for endpoints. */ /******************************************************************************/ /* The best way to think about endpoints is that endpoint is an object created by each nn_bind() or nn_connect() call. Each endpoint is associated with exactly one address string (e.g. "tcp://127.0.0.1:5555"). */ struct nn_epbase; struct nn_epbase_vfptr { /* Ask the endpoint to stop itself. The endpoint is allowed to linger to send the pending outbound data. When done, it reports the fact by invoking nn_epbase_stopped() function. */ void (*stop) (struct nn_epbase *self); /* Deallocate the endpoint object. */ void (*destroy) (struct nn_epbase *self); }; struct nn_epbase { const struct nn_epbase_vfptr *vfptr; struct nn_ep *ep; }; /* Creates a new endpoint. 'hint' parameter is an opaque value that was passed to transport's bind or connect function. */ void nn_epbase_init (struct nn_epbase *self, const struct nn_epbase_vfptr *vfptr, void *hint); /* Notify the user that stopping is done. */ void nn_epbase_stopped (struct nn_epbase *self); /* Terminate the epbase object. */ void nn_epbase_term (struct nn_epbase *self); /* Returns the AIO context associated with the endpoint. */ struct nn_ctx *nn_epbase_getctx (struct nn_epbase *self); /* Returns the address string associated with this endpoint. */ const char *nn_epbase_getaddr (struct nn_epbase *self); /* Retrieve value of a socket option. */ void nn_epbase_getopt (struct nn_epbase *self, int level, int option, void *optval, size_t *optvallen); /* Returns 1 is the specified socket type is a valid peer for this socket, or 0 otherwise. */ int nn_epbase_ispeer (struct nn_epbase *self, int socktype); /* Notifies a monitoring system the error on this endpoint */ void nn_epbase_set_error(struct nn_epbase *self, int errnum); /* Notifies a monitoring system that error is gone */ void nn_epbase_clear_error(struct nn_epbase *self); /* Increments statistics counters in the socket structure */ void nn_epbase_stat_increment(struct nn_epbase *self, int name, int increment); #define NN_STAT_ESTABLISHED_CONNECTIONS 101 #define NN_STAT_ACCEPTED_CONNECTIONS 102 #define NN_STAT_DROPPED_CONNECTIONS 103 #define NN_STAT_BROKEN_CONNECTIONS 104 #define NN_STAT_CONNECT_ERRORS 105 #define NN_STAT_BIND_ERRORS 106 #define NN_STAT_ACCEPT_ERRORS 107 #define NN_STAT_CURRENT_CONNECTIONS 201 #define NN_STAT_INPROGRESS_CONNECTIONS 202 #define NN_STAT_CURRENT_EP_ERRORS 203 /******************************************************************************/ /* The base class for pipes. */ /******************************************************************************/ /* Pipe represents one "connection", i.e. perfectly ordered uni- or bi-directional stream of messages. One endpoint can create multiple pipes (for example, bound TCP socket is an endpoint, individual accepted TCP connections are represented by pipes. */ struct nn_pipebase; /* This value is returned by pipe's send and recv functions to signalise that more sends/recvs are not possible at the moment. From that moment on, the core will stop invoking the function. To re-establish the message flow nn_pipebase_received (respectively nn_pipebase_sent) should be called. */ #define NN_PIPEBASE_RELEASE 1 /* Specifies that received message is already split into header and body. This flag is used only by inproc transport to avoid merging and re-splitting the messages passed with a single process. */ #define NN_PIPEBASE_PARSED 2 struct nn_pipebase_vfptr { /* Send a message to the network. The function can return either error (negative number) or any combination of the flags defined above. */ int (*send) (struct nn_pipebase *self, struct nn_msg *msg); /* Receive a message from the network. The function can return either error (negative number) or any combination of the flags defined above. */ int (*recv) (struct nn_pipebase *self, struct nn_msg *msg); }; /* Endpoint specific options. Same restrictions as for nn_pipebase apply */ struct nn_ep_options { int sndprio; int rcvprio; int ipv4only; }; /* The member of this structure are used internally by the core. Never use or modify them directly from the transport. */ struct nn_pipebase { struct nn_fsm fsm; const struct nn_pipebase_vfptr *vfptr; uint8_t state; uint8_t instate; uint8_t outstate; struct nn_sock *sock; void *data; struct nn_fsm_event in; struct nn_fsm_event out; struct nn_ep_options options; }; /* Initialise the pipe. */ void nn_pipebase_init (struct nn_pipebase *self, const struct nn_pipebase_vfptr *vfptr, struct nn_epbase *epbase); /* Terminate the pipe. */ void nn_pipebase_term (struct nn_pipebase *self); /* Call this function once the connection is established. */ int nn_pipebase_start (struct nn_pipebase *self); /* Call this function once the connection is broken. */ void nn_pipebase_stop (struct nn_pipebase *self); /* Call this function when new message was fully received. */ void nn_pipebase_received (struct nn_pipebase *self); /* Call this function when current outgoing message was fully sent. */ void nn_pipebase_sent (struct nn_pipebase *self); /* Retrieve value of a socket option. */ void nn_pipebase_getopt (struct nn_pipebase *self, int level, int option, void *optval, size_t *optvallen); /* Returns 1 is the specified socket type is a valid peer for this socket, or 0 otherwise. */ int nn_pipebase_ispeer (struct nn_pipebase *self, int socktype); /******************************************************************************/ /* The transport class. */ /******************************************************************************/ struct nn_transport { /* Name of the transport as it appears in the connection strings ("tcp", "ipc", "inproc" etc. */ const char *name; /* ID of the transport. */ int id; /* Following methods are guarded by a global critical section. Two of these function will never be invoked in parallel. The first is called when the library is initialised, the second one when it is terminated, i.e. when there are no more open sockets. Either of them can be set to NULL if no specific initialisation/termination is needed. */ void (*init) (void); void (*term) (void); /* Each of these functions creates an endpoint and returns the newly created endpoint in 'epbase' parameter. 'hint' is in opaque pointer to be passed to nn_epbase_init(). The epbase object can then be used to retrieve the address to bind/connect to. These functions are guarded by a socket-wide critical section. Two of these function will never be invoked in parallel on the same socket. */ int (*bind) (void *hint, struct nn_epbase **epbase); int (*connect) (void *hint, struct nn_epbase **epbase); /* Create an object to hold transport-specific socket options. Set this member to NULL in case there are no transport-specific socket options available. */ struct nn_optset *(*optset) (void); /* This member is used exclusively by the core. Never touch it directly from the transport. */ struct nn_list_item item; }; #endif nanomsg-0.8-beta/src/protocol.h0000664000175000017500000001736212623652600017454 0ustar00travistravis00000000000000/* Copyright (c) 2012-2013 Martin Sustrik 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. */ #ifndef NN_PROTOCOL_INCLUDED #define NN_PROTOCOL_INCLUDED #include "utils/msg.h" #include "utils/list.h" #include "utils/int.h" #include struct nn_ctx; /******************************************************************************/ /* Pipe class. */ /******************************************************************************/ /* Any combination of following flags can be returned from successful call to nn_pipe_send or nn_pipe_recv. */ /* This flag means that the pipe can't be used for receiving (when returned from nn_pipe_recv()) or sending (when returned from nn_pipe_send()). Protocol implementation should not send/recv messages from the pipe until the pipe is revived by in()/out() function. */ #define NN_PIPE_RELEASE 1 /* Specifies that received message is already split into header and body. This flag is used only by inproc transport to avoid merging and re-splitting the messages passed with a single process. */ #define NN_PIPE_PARSED 2 /* Events generated by the pipe. */ #define NN_PIPE_IN 33987 #define NN_PIPE_OUT 33988 struct nn_pipe; /* Associates opaque pointer to protocol-specific data with the pipe. */ void nn_pipe_setdata (struct nn_pipe *self, void *data); /* Retrieves the opaque pointer associated with the pipe. */ void *nn_pipe_getdata (struct nn_pipe *self); /* Send the message to the pipe. If successful, pipe takes ownership of the messages. */ int nn_pipe_send (struct nn_pipe *self, struct nn_msg *msg); /* Receive a message from a pipe. 'msg' should not be initialised prior to the call. It will be initialised when the call succeeds. */ int nn_pipe_recv (struct nn_pipe *self, struct nn_msg *msg); /* Get option for pipe. Mostly useful for endpoint-specific options */ void nn_pipe_getopt (struct nn_pipe *self, int level, int option, void *optval, size_t *optvallen); /******************************************************************************/ /* Base class for all socket types. */ /******************************************************************************/ struct nn_sockbase; /* Any combination of these events can be returned from 'events' virtual function. */ #define NN_SOCKBASE_EVENT_IN 1 #define NN_SOCKBASE_EVENT_OUT 2 /* To be implemented by individual socket types. */ struct nn_sockbase_vfptr { /* Ask socket to stop. */ void (*stop) (struct nn_sockbase *self); /* Deallocate the socket. */ void (*destroy) (struct nn_sockbase *self); /* Management of pipes. 'add' registers a new pipe. The pipe cannot be used to send to or to be received from at the moment. 'rm' unregisters the pipe. The pipe should not be used after this call as it may already be deallocated. 'in' informs the socket that pipe is readable. 'out' informs it that it is writable. */ int (*add) (struct nn_sockbase *self, struct nn_pipe *pipe); void (*rm) (struct nn_sockbase *self, struct nn_pipe *pipe); void (*in) (struct nn_sockbase *self, struct nn_pipe *pipe); void (*out) (struct nn_sockbase *self, struct nn_pipe *pipe); /* Return any combination of event flags defined above, thus specifying whether the socket should be readable, writable, both or none. */ int (*events) (struct nn_sockbase *self); /* Send a message to the socket. Returns -EAGAIN if it cannot be done at the moment or zero in case of success. */ int (*send) (struct nn_sockbase *self, struct nn_msg *msg); /* Receive a message from the socket. Returns -EAGAIN if it cannot be done at the moment or zero in case of success. */ int (*recv) (struct nn_sockbase *self, struct nn_msg *msg); /* Set a protocol specific option. */ int (*setopt) (struct nn_sockbase *self, int level, int option, const void *optval, size_t optvallen); /* Retrieve a protocol specific option. */ int (*getopt) (struct nn_sockbase *self, int level, int option, void *optval, size_t *optvallen); }; struct nn_sockbase { const struct nn_sockbase_vfptr *vfptr; struct nn_sock *sock; }; /* Initialise the socket base class. 'hint' is the opaque value passed to the nn_transport's 'create' function. */ void nn_sockbase_init (struct nn_sockbase *self, const struct nn_sockbase_vfptr *vfptr, void *hint); /* Terminate the socket base class. */ void nn_sockbase_term (struct nn_sockbase *self); /* Call this function when stopping is done. */ void nn_sockbase_stopped (struct nn_sockbase *self); /* Returns the AIO context associated with the socket. This function is useful when socket type implementation needs to create async objects, such as timers. */ struct nn_ctx *nn_sockbase_getctx (struct nn_sockbase *self); /* Retrieve a NN_SOL_SOCKET-level option. */ int nn_sockbase_getopt (struct nn_sockbase *self, int option, void *optval, size_t *optvallen); /* Add some statistics for socket */ void nn_sockbase_stat_increment (struct nn_sockbase *self, int name, int increment); #define NN_STAT_CURRENT_SND_PRIORITY 401 /******************************************************************************/ /* The socktype class. */ /******************************************************************************/ /* This structure defines a class factory for individual socket types. */ /* Specifies that the socket type can be never used to receive messages. */ #define NN_SOCKTYPE_FLAG_NORECV 1 /* Specifies that the socket type can be never used to send messages. */ #define NN_SOCKTYPE_FLAG_NOSEND 2 struct nn_socktype { /* Domain and protocol IDs as specified in nn_socket() function. */ int domain; int protocol; /* Any combination of the flags defined above. */ int flags; /* Function to create specific socket type. 'sockbase' is the output parameter to return reference to newly created socket. This function is called under global lock, so it is not possible that two sockets are being created in parallel. */ int (*create) (void *hint, struct nn_sockbase **sockbase); /* Returns 1 if the supplied socket type is a valid peer for this socket, 0 otherwise. Note that the validation is done only within a single SP protocol. Peers speaking other SP protocols are discarded by the core and socket is not even asked to validate them. */ int (*ispeer) (int socktype); /* This member is owned by the core. Never touch it directly from inside the protocol implementation. */ struct nn_list_item item; }; #endif nanomsg-0.8-beta/src/CMakeLists.txt0000664000175000017500000001651112623652600020175 0ustar00travistravis00000000000000# # Copyright (c) 2012-2013 Martin Sustrik All rights reserved. # Copyright (c) 2013 GoPivotal, Inc. 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. # set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set (NN_SOURCES nn.h inproc.h ipc.h tcp.h ws.h pair.h pubsub.h reqrep.h pipeline.h survey.h bus.h core/ep.h core/ep.c core/epbase.c core/global.h core/global.c core/pipe.c core/poll.c core/sock.h core/sock.c core/sockbase.c core/symbol.c aio/ctx.h aio/ctx.c aio/fsm.h aio/fsm.c aio/poller.h aio/poller.c aio/poller_epoll.h aio/poller_epoll.inc aio/poller_kqueue.h aio/poller_kqueue.inc aio/poller_poll.h aio/poller_poll.inc aio/pool.h aio/pool.c aio/timer.h aio/timer.c aio/timerset.h aio/timerset.c aio/usock.h aio/usock.c aio/usock_posix.h aio/usock_posix.inc aio/usock_win.h aio/usock_win.inc aio/worker.h aio/worker.c aio/worker_posix.h aio/worker_posix.inc aio/worker_win.h aio/worker_win.inc utils/alloc.h utils/alloc.c utils/atomic.h utils/atomic.c utils/attr.h utils/chunk.h utils/chunk.c utils/chunkref.h utils/chunkref.c utils/clock.h utils/clock.c utils/closefd.h utils/closefd.c utils/cont.h utils/efd.h utils/efd.c utils/efd_eventfd.h utils/efd_eventfd.inc utils/efd_pipe.h utils/efd_pipe.inc utils/efd_socketpair.h utils/efd_socketpair.inc utils/efd_win.h utils/efd_win.inc utils/err.h utils/err.c utils/fast.h utils/fd.h utils/glock.h utils/glock.c utils/hash.h utils/hash.c utils/int.h utils/list.h utils/list.c utils/msg.h utils/msg.c utils/mutex.h utils/mutex.c utils/queue.h utils/queue.c utils/random.h utils/random.c utils/sem.h utils/sem.c utils/sleep.h utils/sleep.c utils/thread.h utils/thread.c utils/thread_posix.h utils/thread_posix.inc utils/thread_win.h utils/thread_win.inc utils/wire.h utils/wire.c devices/device.h devices/device.c devices/tcpmuxd.c protocols/utils/dist.h protocols/utils/dist.c protocols/utils/excl.h protocols/utils/excl.c protocols/utils/fq.h protocols/utils/fq.c protocols/utils/lb.h protocols/utils/lb.c protocols/utils/priolist.h protocols/utils/priolist.c protocols/bus/bus.h protocols/bus/bus.c protocols/bus/xbus.h protocols/bus/xbus.c protocols/pipeline/push.h protocols/pipeline/push.c protocols/pipeline/pull.h protocols/pipeline/pull.c protocols/pipeline/xpull.h protocols/pipeline/xpull.c protocols/pipeline/xpush.h protocols/pipeline/xpush.c protocols/pair/pair.h protocols/pair/pair.c protocols/pair/xpair.h protocols/pair/xpair.c protocols/pubsub/pub.h protocols/pubsub/pub.c protocols/pubsub/sub.h protocols/pubsub/sub.c protocols/pubsub/trie.h protocols/pubsub/trie.c protocols/pubsub/xpub.h protocols/pubsub/xpub.c protocols/pubsub/xsub.h protocols/pubsub/xsub.c protocols/reqrep/req.h protocols/reqrep/req.c protocols/reqrep/rep.h protocols/reqrep/rep.c protocols/reqrep/task.h protocols/reqrep/task.c protocols/reqrep/xrep.h protocols/reqrep/xrep.c protocols/reqrep/xreq.h protocols/reqrep/xreq.c protocols/survey/respondent.h protocols/survey/respondent.c protocols/survey/surveyor.h protocols/survey/surveyor.c protocols/survey/xrespondent.h protocols/survey/xrespondent.c protocols/survey/xsurveyor.h protocols/survey/xsurveyor.c transports/utils/backoff.h transports/utils/backoff.c transports/utils/dns.h transports/utils/dns.c transports/utils/dns_getaddrinfo.h transports/utils/dns_getaddrinfo.inc transports/utils/dns_getaddrinfo_a.h transports/utils/dns_getaddrinfo_a.inc transports/utils/iface.h transports/utils/iface.c transports/utils/literal.h transports/utils/literal.c transports/utils/port.h transports/utils/port.c transports/utils/streamhdr.h transports/utils/streamhdr.c transports/utils/base64.h transports/utils/base64.c transports/inproc/binproc.h transports/inproc/binproc.c transports/inproc/cinproc.h transports/inproc/cinproc.c transports/inproc/inproc.h transports/inproc/inproc.c transports/inproc/ins.h transports/inproc/ins.c transports/inproc/msgqueue.h transports/inproc/msgqueue.c transports/inproc/sinproc.h transports/inproc/sinproc.c transports/ipc/aipc.h transports/ipc/aipc.c transports/ipc/bipc.h transports/ipc/bipc.c transports/ipc/cipc.h transports/ipc/cipc.c transports/ipc/ipc.h transports/ipc/ipc.c transports/ipc/sipc.h transports/ipc/sipc.c transports/tcp/atcp.h transports/tcp/atcp.c transports/tcp/btcp.h transports/tcp/btcp.c transports/tcp/ctcp.h transports/tcp/ctcp.c transports/tcp/stcp.h transports/tcp/stcp.c transports/tcp/tcp.h transports/tcp/tcp.c transports/tcpmux/atcpmux.h transports/tcpmux/atcpmux.c transports/tcpmux/btcpmux.h transports/tcpmux/btcpmux.c transports/tcpmux/ctcpmux.h transports/tcpmux/ctcpmux.c transports/tcpmux/stcpmux.h transports/tcpmux/stcpmux.c transports/tcpmux/tcpmux.h transports/tcpmux/tcpmux.c transports/ws/aws.h transports/ws/aws.c transports/ws/bws.h transports/ws/bws.c transports/ws/cws.h transports/ws/cws.c transports/ws/sws.h transports/ws/sws.c transports/ws/ws.h transports/ws/ws.c transports/ws/ws_handshake.h transports/ws/ws_handshake.c transports/ws/sha1.h transports/ws/sha1.c ) if (WIN32) LIST (APPEND NN_SOURCES utils/win.h ) endif () add_library (nanomsg SHARED ${NN_SOURCES}) add_definitions (-DNN_EXPORTS) target_link_libraries (nanomsg ws2_32) target_link_libraries (nanomsg mswsock) target_link_libraries (nanomsg advapi32) install(TARGETS nanomsg ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) nanomsg-0.8-beta/tests/0000775000175000017500000000000012623652617016014 5ustar00travistravis00000000000000nanomsg-0.8-beta/tests/async_shutdown.c0000664000175000017500000000444412623652600021226 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik All rights reserved. Copyright (c) 2015 Jack R. Dunaway. 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 "../src/nn.h" #include "../src/pair.h" #include "../src/pubsub.h" #include "../src/pipeline.h" #include "../src/tcp.h" #include "testutil.h" #include "../src/utils/attr.h" #include "../src/utils/thread.c" #include "../src/utils/atomic.c" /* Test condition of closing sockets that are blocking in another thread. */ #define TEST_LOOPS 10 #define SOCKET_ADDRESS "tcp://127.0.0.1:5557" struct nn_atomic active; static void routine (NN_UNUSED void *arg) { int s; int rc; int msg; nn_assert (arg); s = *((int *) arg); /* We don't expect to actually receive a message here; therefore, the datatype of 'msg' is irrelevant. */ rc = nn_recv (s, &msg, sizeof(msg), 0); errno_assert (nn_errno () == EBADF); } int main () { int sb; int i; struct nn_thread thread; for (i = 0; i != TEST_LOOPS; ++i) { sb = test_socket (AF_SP, NN_PULL); test_bind (sb, SOCKET_ADDRESS); nn_sleep (100); nn_thread_init (&thread, routine, &sb); nn_sleep (100); test_close (sb); nn_thread_term (&thread); } return 0; } nanomsg-0.8-beta/tests/block.c0000664000175000017500000000406412623652600017246 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "testutil.h" #include "../src/utils/attr.h" #include "../src/utils/thread.c" /* This test checks whether blocking on send/recv works as expected. */ #define SOCKET_ADDRESS "inproc://a" int sc; int sb; void worker (NN_UNUSED void *arg) { /* Wait 0.1 sec for the main thread to block. */ nn_sleep (100); test_send (sc, "ABC"); /* Wait 0.1 sec for the main thread to process the previous message and block once again. */ nn_sleep (100); test_send (sc, "ABC"); } int main () { struct nn_thread thread; sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); nn_thread_init (&thread, worker, NULL); test_recv (sb, "ABC"); test_recv (sb, "ABC"); nn_thread_term (&thread); test_close (sc); test_close (sb); return 0; } nanomsg-0.8-beta/tests/bug328.c0000664000175000017500000000336212623652600017166 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "testutil.h" #define SOCKET_ADDRESS "tcp://127.0.0.1:5777" int main () { int sb; int sc; int s1; sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); s1 = test_socket (AF_SP, NN_PAIR); test_bind (s1, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); nn_sleep(100); test_send (sc, "ABC"); test_recv (sb, "ABC"); test_close (sb); nn_sleep(300); test_send (s1, "ABC"); test_recv (sc, "ABC"); test_close (sc); test_close (s1); return 0; } nanomsg-0.8-beta/tests/bus.c0000664000175000017500000000524512623652600016747 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/bus.h" #include "testutil.h" #define SOCKET_ADDRESS_A "inproc://a" #define SOCKET_ADDRESS_B "inproc://b" int main () { int rc; int bus1; int bus2; int bus3; char buf [3]; /* Create a simple bus topology consisting of 3 nodes. */ bus1 = test_socket (AF_SP, NN_BUS); test_bind (bus1, SOCKET_ADDRESS_A); bus2 = test_socket (AF_SP, NN_BUS); test_bind (bus2, SOCKET_ADDRESS_B); test_connect (bus2, SOCKET_ADDRESS_A); bus3 = test_socket (AF_SP, NN_BUS); test_connect (bus3, SOCKET_ADDRESS_A); test_connect (bus3, SOCKET_ADDRESS_B); /* Send a message from each node. */ test_send (bus1, "A"); test_send (bus2, "AB"); test_send (bus3, "ABC"); /* Check that two messages arrived at each node. */ rc = nn_recv (bus1, buf, 3, 0); errno_assert (rc >= 0); nn_assert (rc == 2 || rc == 3); rc = nn_recv (bus1, buf, 3, 0); errno_assert (rc >= 0); nn_assert (rc == 2 || rc == 3); rc = nn_recv (bus2, buf, 3, 0); errno_assert (rc >= 0); nn_assert (rc == 1 || rc == 3); rc = nn_recv (bus2, buf, 3, 0); errno_assert (rc >= 0); nn_assert (rc == 1 || rc == 3); rc = nn_recv (bus3, buf, 3, 0); errno_assert (rc >= 0); nn_assert (rc == 1 || rc == 2); rc = nn_recv (bus3, buf, 3, 0); errno_assert (rc >= 0); nn_assert (rc == 1 || rc == 2); /* Wait till both connections are established. */ nn_sleep (10); test_close (bus3); test_close (bus2); test_close (bus1); return 0; } nanomsg-0.8-beta/tests/cmsg.c0000664000175000017500000000664412623652600017113 0ustar00travistravis00000000000000/* Copyright (c) 2014 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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 "../src/nn.h" #include "../src/tcp.h" #include "../src/reqrep.h" #include "testutil.h" #define SOCKET_ADDRESS "tcp://127.0.0.1:5555" int main () { int rc; int rep; int req; struct nn_msghdr hdr; struct nn_iovec iovec; unsigned char body [3]; unsigned char ctrl [256]; struct nn_cmsghdr *cmsg; unsigned char *data; void *buf; rep = test_socket (AF_SP_RAW, NN_REP); test_bind (rep, SOCKET_ADDRESS); req = test_socket (AF_SP, NN_REQ); test_connect (req, SOCKET_ADDRESS); /* Test ancillary data in static buffer. */ test_send (req, "ABC"); iovec.iov_base = body; iovec.iov_len = sizeof (body); hdr.msg_iov = &iovec; hdr.msg_iovlen = 1; hdr.msg_control = ctrl; hdr.msg_controllen = sizeof (ctrl); rc = nn_recvmsg (rep, &hdr, 0); errno_assert (rc == 3); cmsg = NN_CMSG_FIRSTHDR (&hdr); while (1) { nn_assert (cmsg); if (cmsg->cmsg_level == PROTO_SP && cmsg->cmsg_type == SP_HDR) break; cmsg = NN_CMSG_NXTHDR (&hdr, cmsg); } nn_assert (cmsg->cmsg_len == NN_CMSG_SPACE (8+sizeof (size_t))); data = NN_CMSG_DATA (cmsg); nn_assert (!(data[0+sizeof (size_t)] & 0x80)); nn_assert (data[4+sizeof (size_t)] & 0x80); rc = nn_sendmsg (rep, &hdr, 0); nn_assert (rc == 3); test_recv (req, "ABC"); /* Test ancillary data in dynamically allocated buffer (NN_MSG). */ test_send (req, "ABC"); iovec.iov_base = body; iovec.iov_len = sizeof (body); hdr.msg_iov = &iovec; hdr.msg_iovlen = 1; hdr.msg_control = &buf; hdr.msg_controllen = NN_MSG; rc = nn_recvmsg (rep, &hdr, 0); errno_assert (rc == 3); cmsg = NN_CMSG_FIRSTHDR (&hdr); while (1) { nn_assert (cmsg); if (cmsg->cmsg_level == PROTO_SP && cmsg->cmsg_type == SP_HDR) break; cmsg = NN_CMSG_NXTHDR (&hdr, cmsg); } nn_assert (cmsg->cmsg_len == NN_CMSG_SPACE (8+sizeof (size_t))); data = NN_CMSG_DATA (cmsg); nn_assert (!(data[0+sizeof (size_t)] & 0x80)); nn_assert (data[4+sizeof (size_t)] & 0x80); rc = nn_sendmsg (rep, &hdr, 0); nn_assert (rc == 3); test_recv (req, "ABC"); test_close (req); test_close (rep); return 0; } nanomsg-0.8-beta/tests/device.c0000664000175000017500000001217612623652600017416 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "../src/nn.h" #include "../src/bus.h" #include "../src/pair.h" #include "../src/pipeline.h" #include "../src/inproc.h" #include "testutil.h" #include "../src/utils/attr.h" #include "../src/utils/thread.c" #define SOCKET_ADDRESS_A "inproc://a" #define SOCKET_ADDRESS_B "inproc://b" #define SOCKET_ADDRESS_C "inproc://c" #define SOCKET_ADDRESS_D "inproc://d" #define SOCKET_ADDRESS_E "inproc://e" void device1 (NN_UNUSED void *arg) { int rc; int deva; int devb; /* Intialise the device sockets. */ deva = test_socket (AF_SP_RAW, NN_PAIR); test_bind (deva, SOCKET_ADDRESS_A); devb = test_socket (AF_SP_RAW, NN_PAIR); test_bind (devb, SOCKET_ADDRESS_B); /* Run the device. */ rc = nn_device (deva, devb); nn_assert (rc < 0 && (nn_errno () == ETERM || nn_errno () == EBADF)); /* Clean up. */ test_close (devb); test_close (deva); } void device2 (NN_UNUSED void *arg) { int rc; int devc; int devd; /* Intialise the device sockets. */ devc = test_socket (AF_SP_RAW, NN_PULL); test_bind (devc, SOCKET_ADDRESS_C); devd = test_socket (AF_SP_RAW, NN_PUSH); test_bind (devd, SOCKET_ADDRESS_D); /* Run the device. */ rc = nn_device (devc, devd); nn_assert (rc < 0 && nn_errno () == ETERM); /* Clean up. */ test_close (devd); test_close (devc); } void device3 (NN_UNUSED void *arg) { int rc; int deve; /* Intialise the device socket. */ deve = test_socket (AF_SP_RAW, NN_BUS); test_bind (deve, SOCKET_ADDRESS_E); /* Run the device. */ rc = nn_device (deve, -1); nn_assert (rc < 0 && nn_errno () == ETERM); /* Clean up. */ test_close (deve); } int main () { int enda; int endb; int endc; int endd; int ende1; int ende2; struct nn_thread thread1; struct nn_thread thread2; struct nn_thread thread3; int timeo; /* Test the bi-directional device. */ /* Start the device. */ nn_thread_init (&thread1, device1, NULL); /* Create two sockets to connect to the device. */ enda = test_socket (AF_SP, NN_PAIR); test_connect (enda, SOCKET_ADDRESS_A); endb = test_socket (AF_SP, NN_PAIR); test_connect (endb, SOCKET_ADDRESS_B); /* Pass a pair of messages between endpoints. */ test_send (enda, "ABC"); test_recv (endb, "ABC"); test_send (endb, "ABC"); test_recv (enda, "ABC"); /* Clean up. */ test_close (endb); test_close (enda); /* Test the uni-directional device. */ /* Start the device. */ nn_thread_init (&thread2, device2, NULL); /* Create two sockets to connect to the device. */ endc = test_socket (AF_SP, NN_PUSH); test_connect (endc, SOCKET_ADDRESS_C); endd = test_socket (AF_SP, NN_PULL); test_connect (endd, SOCKET_ADDRESS_D); /* Pass a message between endpoints. */ test_send (endc, "XYZ"); test_recv (endd, "XYZ"); /* Clean up. */ test_close (endd); test_close (endc); /* Test the loopback device. */ /* Start the device. */ nn_thread_init (&thread3, device3, NULL); /* Create two sockets to connect to the device. */ ende1 = test_socket (AF_SP, NN_BUS); test_connect (ende1, SOCKET_ADDRESS_E); ende2 = test_socket (AF_SP, NN_BUS); test_connect (ende2, SOCKET_ADDRESS_E); /* BUS is unreliable so wait a bit for connections to be established. */ nn_sleep (100); /* Pass a message to the bus. */ test_send (ende1, "KLM"); test_recv (ende2, "KLM"); /* Make sure that the message doesn't arrive at the socket it was originally sent to. */ timeo = 100; test_setsockopt (ende1, NN_SOL_SOCKET, NN_RCVTIMEO, &timeo, sizeof (timeo)); test_drop (ende1, ETIMEDOUT); /* Clean up. */ test_close (ende2); test_close (ende1); /* Shut down the devices. */ nn_term (); nn_thread_term (&thread1); nn_thread_term (&thread2); nn_thread_term (&thread3); return 0; } nanomsg-0.8-beta/tests/device4.c0000664000175000017500000000550712623652600017502 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. All rights reserved. Copyright 2015 Garrett D'Amore 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 "../src/nn.h" #include "../src/reqrep.h" #include "../src/tcp.h" #include "testutil.h" #include "../src/utils/attr.h" #include "../src/utils/thread.c" #define SOCKET_ADDRESS_F "tcp://127.0.0.1:5565" #define SOCKET_ADDRESS_G "tcp://127.0.0.1:5566" void device4 (NN_UNUSED void *arg) { int rc; int devf; int devg; /* Intialise the device sockets. */ devf = test_socket (AF_SP_RAW, NN_REP); test_bind (devf, SOCKET_ADDRESS_F); devg = test_socket (AF_SP_RAW, NN_REQ); test_bind (devg, SOCKET_ADDRESS_G); /* Run the device. */ rc = nn_device (devf, devg); nn_assert (rc < 0 && (nn_errno () == ETERM || nn_errno () == EBADF)); /* Clean up. */ test_close (devg); test_close (devf); } int main () { int endf; int endg; struct nn_thread thread4; /* Test the bi-directional device with REQ/REP (headers). */ /* Start the device. */ nn_thread_init (&thread4, device4, NULL); /* Create two sockets to connect to the device. */ endf = test_socket (AF_SP, NN_REQ); test_connect (endf, SOCKET_ADDRESS_F); endg = test_socket (AF_SP, NN_REP); test_connect (endg, SOCKET_ADDRESS_G); /* Wait for TCP to establish. */ nn_sleep (100); /* Pass a message between endpoints. */ test_send (endf, "XYZ"); test_recv (endg, "XYZ"); /* Now send a reply. */ test_send (endg, "REPLYXYZ"); test_recv (endf, "REPLYXYZ"); /* Clean up. */ test_close (endg); test_close (endf); /* Shut down the devices. */ nn_term (); nn_thread_term (&thread4); return 0; } nanomsg-0.8-beta/tests/device5.c0000664000175000017500000000656612623652600017511 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. All rights reserved. Copyright 2015 Garrett D'Amore 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 "../src/nn.h" #include "../src/reqrep.h" #include "../src/tcp.h" #include "testutil.h" #include "../src/utils/attr.h" #include "../src/utils/thread.c" #define SOCKET_ADDRESS_H "tcp://127.0.0.1:5567" #define SOCKET_ADDRESS_I "tcp://127.0.0.1:5568" #define SOCKET_ADDRESS_J "tcp://127.0.0.1:5569" void device5 (NN_UNUSED void *arg) { int rc; int dev0; int dev1; /* Intialise the device sockets. */ dev0 = test_socket (AF_SP_RAW, NN_REP); test_bind (dev0, SOCKET_ADDRESS_H); dev1 = test_socket (AF_SP_RAW, NN_REQ); test_bind (dev1, SOCKET_ADDRESS_I); /* Run the device. */ rc = nn_device (dev0, dev1); nn_assert (rc < 0 && nn_errno () == ETERM); /* Clean up. */ test_close (dev0); test_close (dev1); } void device6 (NN_UNUSED void *arg) { int rc; int dev2; int dev3; dev2 = test_socket (AF_SP_RAW, NN_REP); test_connect (dev2, SOCKET_ADDRESS_I); dev3 = test_socket (AF_SP_RAW, NN_REQ); test_bind (dev3, SOCKET_ADDRESS_J); /* Run the device. */ rc = nn_device (dev2, dev3); nn_assert (rc < 0 && nn_errno () == ETERM); /* Clean up. */ test_close (dev2); test_close (dev3); } int main () { int end0; int end1; struct nn_thread thread5; struct nn_thread thread6; /* Test the bi-directional device with REQ/REP (headers). */ /* Start the devices. */ nn_thread_init (&thread5, device5, NULL); nn_thread_init (&thread6, device6, NULL); /* Create two sockets to connect to the device. */ end0 = test_socket (AF_SP, NN_REQ); test_connect (end0, SOCKET_ADDRESS_H); end1 = test_socket (AF_SP, NN_REP); test_connect (end1, SOCKET_ADDRESS_J); /* Wait for TCP to establish. */ nn_sleep (100); /* Pass a message between endpoints. */ test_send (end0, "XYZ"); test_recv (end1, "XYZ"); /* Now send a reply. */ test_send (end1, "REPLYXYZ"); test_recv (end0, "REPLYXYZ"); /* Clean up. */ test_close (end0); test_close (end1); /* Shut down the devices. */ nn_term (); nn_thread_term (&thread5); nn_thread_term (&thread6); return 0; } nanomsg-0.8-beta/tests/domain.c0000664000175000017500000000340712623652600017423 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "testutil.h" /* Test the NN_DOMAIN and NN_PROTOCOL socket options. */ int main () { int rc; int s; int op; size_t opsz; s = test_socket (AF_SP, NN_PAIR); opsz = sizeof (op); rc = nn_getsockopt (s, NN_SOL_SOCKET, NN_DOMAIN, &op, &opsz); errno_assert (rc == 0); nn_assert (opsz == sizeof (op)); nn_assert (op == AF_SP); opsz = sizeof (op); rc = nn_getsockopt (s, NN_SOL_SOCKET, NN_PROTOCOL, &op, &opsz); errno_assert (rc == 0); nn_assert (opsz == sizeof (op)); nn_assert (op == NN_PAIR); test_close (s); return 0; } nanomsg-0.8-beta/tests/emfile.c0000664000175000017500000000343212623652600017413 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "../src/tcp.h" #include "../src/utils/err.c" #define SOCKET_ADDRESS "tcp://127.0.0.1:5555" #define MAX_SOCKETS 1000 int main () { int rc; int i; int socks [MAX_SOCKETS]; /* First, just create as much SP sockets as possible. */ for (i = 0; i != MAX_SOCKETS; ++i) { socks [i] = nn_socket (AF_SP, NN_PAIR); if (socks [i] < 0) { errno_assert (nn_errno () == EMFILE); break; } } while (1) { --i; if (i == -1) break; rc = nn_close (socks [i]); errno_assert (rc == 0); } return 0; } nanomsg-0.8-beta/tests/hash.c0000664000175000017500000000412012623652600017070 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "../src/utils/err.c" #include "../src/utils/list.c" #include "../src/utils/hash.c" #include "../src/utils/alloc.c" int main () { struct nn_hash hash; uint32_t k; struct nn_hash_item *item; struct nn_hash_item *item5000 = NULL; nn_hash_init (&hash); /* Insert 10000 elements into the hash table. */ for (k = 0; k != 10000; ++k) { item = nn_alloc (sizeof (struct nn_hash_item), "item"); nn_assert (item); if (k == 5000) item5000 = item; nn_hash_item_init (item); nn_hash_insert (&hash, k, item); } /* Find one element and check whether it is the correct one. */ nn_assert (nn_hash_get (&hash, 5000) == item5000); /* Remove all the elements from the hash table and terminate it. */ for (k = 0; k != 10000; ++k) { item = nn_hash_get (&hash, k); nn_hash_erase (&hash, item); nn_free (item); } nn_hash_term (&hash); return 0; } nanomsg-0.8-beta/tests/inproc.c0000664000175000017500000001412712623652600017447 0ustar00travistravis00000000000000 /* Copyright (c) 2012 Martin Sustrik 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 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 "../src/nn.h" #include "../src/bus.h" #include "../src/pair.h" #include "../src/pubsub.h" #include "../src/reqrep.h" #include "../src/inproc.h" #include "testutil.h" /* Tests inproc transport. */ #define SOCKET_ADDRESS "inproc://test" int main () { int rc; int sb; int sc; int s1, s2; int i; char buf [256]; int val; struct nn_msghdr hdr; struct nn_iovec iovec; unsigned char body [3]; void *control; struct nn_cmsghdr *cmsg; unsigned char *data; /* Create a simple topology. */ sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); /* Try a duplicate bind. It should fail. */ rc = nn_bind (sc, SOCKET_ADDRESS); nn_assert (rc < 0 && errno == EADDRINUSE); /* Ping-pong test. */ for (i = 0; i != 100; ++i) { test_send (sc, "ABC"); test_recv (sb, "ABC"); test_send (sb, "DEFG"); test_recv (sc, "DEFG"); } /* Batch transfer test. */ for (i = 0; i != 100; ++i) { test_send (sc, "XYZ"); } for (i = 0; i != 100; ++i) { test_recv (sb, "XYZ"); } test_close (sc); test_close (sb); /* Test whether queue limits are observed. */ sb = test_socket (AF_SP, NN_PAIR); val = 200; test_setsockopt (sb, NN_SOL_SOCKET, NN_RCVBUF, &val, sizeof (val)); test_bind (sb, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); val = 200; test_setsockopt (sc, NN_SOL_SOCKET, NN_SNDTIMEO, &val, sizeof (val)); i = 0; while (1) { rc = nn_send (sc, "0123456789", 10, 0); if (rc < 0 && nn_errno () == ETIMEDOUT) break; errno_assert (rc >= 0); nn_assert (rc == 10); ++i; } nn_assert (i == 20); test_recv (sb, "0123456789"); test_send (sc, "0123456789"); rc = nn_send (sc, "0123456789", 10, 0); nn_assert (rc < 0 && nn_errno () == ETIMEDOUT); for (i = 0; i != 20; ++i) { test_recv (sb, "0123456789"); } /* Make sure that even a message that doesn't fit into the buffers gets across. */ for (i = 0; i != sizeof (buf); ++i) buf [i] = 'A'; rc = nn_send (sc, buf, 256, 0); errno_assert (rc >= 0); nn_assert (rc == 256); rc = nn_recv (sb, buf, sizeof (buf), 0); errno_assert (rc >= 0); nn_assert (rc == 256); test_close (sc); test_close (sb); #if 0 /* Test whether connection rejection is handled decently. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); s1 = test_socket (AF_SP, NN_PAIR); test_connect (s1, SOCKET_ADDRESS); s2 = test_socket (AF_SP, NN_PAIR); test_connect (s2, SOCKET_ADDRESS); nn_sleep (100); test_close (s2); test_close (s1); test_close (sb); #endif /* Check whether SP message header is transferred correctly. */ sb = test_socket (AF_SP_RAW, NN_REP); test_bind (sb, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_REQ); test_connect (sc, SOCKET_ADDRESS); test_send (sc, "ABC"); iovec.iov_base = body; iovec.iov_len = sizeof (body); hdr.msg_iov = &iovec; hdr.msg_iovlen = 1; hdr.msg_control = &control; hdr.msg_controllen = NN_MSG; rc = nn_recvmsg (sb, &hdr, 0); errno_assert (rc == 3); cmsg = NN_CMSG_FIRSTHDR (&hdr); while (1) { nn_assert (cmsg); if (cmsg->cmsg_level == PROTO_SP && cmsg->cmsg_type == SP_HDR) break; cmsg = NN_CMSG_NXTHDR (&hdr, cmsg); } nn_assert (cmsg->cmsg_len == NN_CMSG_SPACE (8+sizeof (size_t))); data = NN_CMSG_DATA (cmsg); nn_assert (!(data[0+sizeof (size_t)] & 0x80)); nn_assert (data[4+sizeof (size_t)] & 0x80); nn_freemsg (control); test_close (sc); test_close (sb); /* Test binding a new socket after originally bound socket shuts down. */ sb = test_socket (AF_SP, NN_BUS); test_bind (sb, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_BUS); test_connect (sc, SOCKET_ADDRESS); s1 = test_socket (AF_SP, NN_BUS); test_connect (s1, SOCKET_ADDRESS); /* Close bound socket, leaving connected sockets connect. */ test_close (sb); nn_sleep (100); /* Rebind a new socket to the address to which our connected sockets are listening. */ s2 = test_socket (AF_SP, NN_BUS); test_bind (s2, SOCKET_ADDRESS); /* Ping-pong test. */ for (i = 0; i != 100; ++i) { test_send (sc, "ABC"); test_send (s1, "QRS"); test_recv (s2, "ABC"); test_recv (s2, "QRS"); test_send (s2, "DEFG"); test_recv (sc, "DEFG"); test_recv (s1, "DEFG"); } /* Batch transfer test. */ for (i = 0; i != 100; ++i) { test_send (sc, "XYZ"); } for (i = 0; i != 100; ++i) { test_recv (s2, "XYZ"); } for (i = 0; i != 100; ++i) { test_send (s1, "MNO"); } for (i = 0; i != 100; ++i) { test_recv (s2, "MNO"); } test_close (s1); test_close (sc); test_close (s2); return 0; } nanomsg-0.8-beta/tests/inproc_shutdown.c0000664000175000017500000000416212623652600021400 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "../src/pubsub.h" #include "../src/inproc.h" #include "testutil.h" #include "../src/utils/attr.h" #include "../src/utils/thread.c" /* Stress test the inproc transport. */ #define THREAD_COUNT 100 #define SOCKET_ADDRESS "inproc://test" static void routine (NN_UNUSED void *arg) { int s; s = nn_socket (AF_SP, NN_SUB); if (s < 0 && nn_errno () == EMFILE) return; errno_assert (s >= 0); test_connect (s, SOCKET_ADDRESS); test_close (s); } int main () { int sb; int i; int j; struct nn_thread threads [THREAD_COUNT]; /* Stress the shutdown algorithm. */ sb = test_socket (AF_SP, NN_PUB); test_bind (sb, SOCKET_ADDRESS); for (j = 0; j != 10; ++j) { for (i = 0; i != THREAD_COUNT; ++i) nn_thread_init (&threads [i], routine, NULL); for (i = 0; i != THREAD_COUNT; ++i) nn_thread_term (&threads [i]); } test_close (sb); return 0; } nanomsg-0.8-beta/tests/iovec.c0000664000175000017500000000426712623652600017266 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "testutil.h" #include #define SOCKET_ADDRESS "inproc://a" int main () { int rc; int sb; int sc; struct nn_iovec iov [2]; struct nn_msghdr hdr; char buf [6]; sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); iov [0].iov_base = "AB"; iov [0].iov_len = 2; iov [1].iov_base = "CDEF"; iov [1].iov_len = 4; memset (&hdr, 0, sizeof (hdr)); hdr.msg_iov = iov; hdr.msg_iovlen = 2; rc = nn_sendmsg (sc, &hdr, 0); errno_assert (rc >= 0); nn_assert (rc == 6); iov [0].iov_base = buf; iov [0].iov_len = 4; iov [1].iov_base = buf + 4; iov [1].iov_len = 2; memset (&hdr, 0, sizeof (hdr)); hdr.msg_iov = iov; hdr.msg_iovlen = 2; rc = nn_recvmsg (sb, &hdr, 0); errno_assert (rc >= 0); nn_assert (rc == 6); nn_assert (memcmp (buf, "ABCDEF", 6) == 0); test_close (sc); test_close (sb); return 0; } nanomsg-0.8-beta/tests/ipc.c0000664000175000017500000000776512623652600016742 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "../src/pubsub.h" #include "../src/ipc.h" #include "testutil.h" /* Tests IPC transport. */ #define SOCKET_ADDRESS "ipc://test.ipc" int main () { int sb; int sc; int i; int s1, s2; int size; char * buf; /* Try closing a IPC socket while it not connected. */ sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); test_close (sc); /* Open the socket anew. */ sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); /* Leave enough time for at least one re-connect attempt. */ nn_sleep (200); sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); /* Ping-pong test. */ for (i = 0; i != 1; ++i) { test_send (sc, "0123456789012345678901234567890123456789"); test_recv (sb, "0123456789012345678901234567890123456789"); test_send (sb, "0123456789012345678901234567890123456789"); test_recv (sc, "0123456789012345678901234567890123456789"); } /* Batch transfer test. */ for (i = 0; i != 100; ++i) { test_send (sc, "XYZ"); } for (i = 0; i != 100; ++i) { test_recv (sb, "XYZ"); } /* Send something large enough to trigger overlapped I/O on Windows. */ size = 10000; buf = malloc (size); for (i = 0; i < size; ++i) { buf[i] = 48 + i % 10; } buf[size-1] = '\0'; test_send (sc, buf); test_recv (sb, buf); free (buf); test_close (sc); test_close (sb); /* Test whether connection rejection is handled decently. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); s1 = test_socket (AF_SP, NN_PAIR); test_connect (s1, SOCKET_ADDRESS); s2 = test_socket (AF_SP, NN_PAIR); test_connect (s2, SOCKET_ADDRESS); nn_sleep (100); test_close (s2); test_close (s1); test_close (sb); /* Test two sockets binding to the same address. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); s1 = test_socket (AF_SP, NN_PAIR); test_bind (s1, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); nn_sleep (100); test_send (sb, "ABC"); test_recv (sc, "ABC"); test_close (sb); test_send (s1, "ABC"); test_recv (sc, "ABC"); test_close (sc); test_close (s1); /* Test closing a socket that is waiting to bind. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); nn_sleep (100); s1 = test_socket (AF_SP, NN_PAIR); test_bind (s1, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); nn_sleep (100); test_send (sb, "ABC"); test_recv (sc, "ABC"); test_close (s1); test_send (sb, "ABC"); test_recv (sc, "ABC"); test_close (sb); test_close (sc); return 0; } nanomsg-0.8-beta/tests/ipc_shutdown.c0000664000175000017500000000623012623652600020657 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "../src/pubsub.h" #include "../src/pipeline.h" #include "../src/ipc.h" #include "testutil.h" #include "../src/utils/thread.c" /* Stress test the IPC transport. */ #define THREAD_COUNT 100 #define TEST2_THREAD_COUNT 10 #define MESSAGES_PER_THREAD 10 #define TEST_LOOPS 10 #define SOCKET_ADDRESS "ipc://test-shutdown.ipc" volatile int active; static void routine (NN_UNUSED void *arg) { int s; s = nn_socket (AF_SP, NN_SUB); if (s < 0 && nn_errno () == EMFILE) return; errno_assert (s >= 0); test_connect (s, SOCKET_ADDRESS); test_close (s); } static void routine2 (NN_UNUSED void *arg) { int s; int i; s = test_socket (AF_SP, NN_PULL); for (i = 0; i < 10; ++i) { test_connect (s, SOCKET_ADDRESS); } for (i = 0; i < MESSAGES_PER_THREAD; ++i) { test_recv (s, "hello"); } test_close (s); active --; } int main () { int sb; int i; int j; struct nn_thread threads [THREAD_COUNT]; /* Stress the shutdown algorithm. */ #if defined(SIGPIPE) && defined(SIG_IGN) signal (SIGPIPE, SIG_IGN); #endif sb = test_socket (AF_SP, NN_PUB); test_bind (sb, SOCKET_ADDRESS); for (j = 0; j != TEST_LOOPS; ++j) { for (i = 0; i != THREAD_COUNT; ++i) nn_thread_init (&threads [i], routine, NULL); for (i = 0; i != THREAD_COUNT; ++i) nn_thread_term (&threads [i]); } test_close (sb); /* Test race condition of sending message while socket shutting down */ sb = test_socket (AF_SP, NN_PUSH); test_bind (sb, SOCKET_ADDRESS); for (j = 0; j != TEST_LOOPS; ++j) { for (i = 0; i != TEST2_THREAD_COUNT; ++i) nn_thread_init (&threads [i], routine2, NULL); active = TEST2_THREAD_COUNT; while (active) { (void) nn_send (sb, "hello", 5, NN_DONTWAIT); } for (i = 0; i != TEST2_THREAD_COUNT; ++i) nn_thread_term (&threads [i]); } test_close (sb); return 0; } nanomsg-0.8-beta/tests/ipc_stress.c0000664000175000017500000000652312623652600020334 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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 "../src/nn.h" #include "../src/pair.h" #include "../src/pubsub.h" #include "../src/pipeline.h" #include "../src/ipc.h" #include "testutil.h" #include "../src/utils/thread.c" #include "../src/utils/atomic.h" #include "../src/utils/atomic.c" /* Stress test the IPC transport. */ #define THREAD_COUNT 10 #define TEST_LOOPS 10 #define SOCKET_ADDRESS "ipc://test-stress.ipc" struct nn_atomic active; static void server(NN_UNUSED void *arg) { int bytes; int sock = nn_socket(AF_SP, NN_PULL); nn_assert(sock >= 0); nn_assert(nn_bind(sock, SOCKET_ADDRESS) >= 0); while (1) { char *buf = NULL; if (!active.n) break; bytes = nn_recv(sock, &buf, NN_MSG, 0); nn_assert(bytes >= 0); nn_freemsg(buf); } nn_close(sock); } static void client(NN_UNUSED void *arg) { int bytes; char msg[] = "0"; int sz_msg = strlen (msg) + 1; // '\0' too int i; for (i = 0; i < TEST_LOOPS; i++) { int cli_sock = nn_socket(AF_SP, NN_PUSH); nn_assert(cli_sock >= 0); nn_assert(nn_connect(cli_sock, SOCKET_ADDRESS) >= 0); /* Give time to allow for connect to establish. */ nn_sleep(50); bytes = nn_send(cli_sock, msg, sz_msg, 0); /* This would better be handled via semaphore or condvar. */ nn_sleep(100); nn_assert(bytes == sz_msg); nn_close(cli_sock); } nn_atomic_dec(&active, 1); } int main() { int i; int cli_sock; int bytes; struct nn_thread srv_thread; struct nn_thread cli_threads[THREAD_COUNT]; nn_atomic_init (&active, THREAD_COUNT); /* Stress the shutdown algorithm. */ nn_thread_init(&srv_thread, server, NULL); for (i = 0; i != THREAD_COUNT; ++i) nn_thread_init(&cli_threads[i], client, NULL); for (i = 0; i != THREAD_COUNT; ++i) nn_thread_term(&cli_threads[i]); active.n = 0; cli_sock = nn_socket(AF_SP, NN_PUSH); nn_assert(cli_sock >= 0); nn_assert(nn_connect(cli_sock, SOCKET_ADDRESS) >= 0); bytes = nn_send(cli_sock, &i, sizeof(i), 0); nn_assert(bytes == sizeof(i)); nn_close(cli_sock); nn_thread_term(&srv_thread); return 0; } nanomsg-0.8-beta/tests/list.c0000664000175000017500000001313012623652600017121 0ustar00travistravis00000000000000/* Copyright (c) 2013 Nir Soffer 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 "../src/utils/cont.h" #include "../src/utils/err.c" #include "../src/utils/list.c" static struct nn_list_item sentinel; /* Typical object that can be added to a list. */ struct item { int value; struct nn_list_item item; }; /* Initializing list items statically so they can be inserted into a list. */ static struct item that = {1, NN_LIST_ITEM_INITIALIZER}; static struct item other = {2, NN_LIST_ITEM_INITIALIZER}; int main () { int rc; struct nn_list list; struct nn_list_item *list_item; struct item *item; /* List item life cycle. */ /* Initialize the item. Make sure it's not part of any list. */ nn_list_item_init (&that.item); nn_assert (!nn_list_item_isinlist (&that.item)); /* That may be part of some list, or uninitialized memory. */ that.item.prev = &sentinel; that.item.next = &sentinel; nn_assert (nn_list_item_isinlist (&that.item)); that.item.prev = NULL; that.item.next = NULL; nn_assert (nn_list_item_isinlist (&that.item)); /* Before termination, item must be removed from the list. */ nn_list_item_init (&that.item); nn_list_item_term (&that.item); /* Initializing a list. */ /* Uninitialized list has random content. */ list.first = &sentinel; list.last = &sentinel; nn_list_init (&list); nn_assert (list.first == NULL); nn_assert (list.last == NULL); nn_list_term (&list); /* Empty list. */ nn_list_init (&list); rc = nn_list_empty (&list); nn_assert (rc == 1); list_item = nn_list_begin (&list); nn_assert (list_item == NULL); list_item = nn_list_end (&list); nn_assert (list_item == NULL); nn_list_term (&list); /* Inserting and erasing items. */ nn_list_init (&list); nn_list_item_init (&that.item); /* Item doesn'tt belong to list yet. */ nn_assert (!nn_list_item_isinlist (&that.item)); nn_list_insert (&list, &that.item, nn_list_end (&list)); /* Item is now part of a list. */ nn_assert (nn_list_item_isinlist (&that.item)); /* Single item does not have prev or next item. */ nn_assert (that.item.prev == NULL); nn_assert (that.item.next == NULL); /* Item is both first and list item. */ nn_assert (list.first == &that.item); nn_assert (list.last == &that.item); /* Removing an item. */ nn_list_erase (&list, &that.item); nn_assert (!nn_list_item_isinlist (&that.item)); nn_assert (list.first == NULL); nn_assert (list.last == NULL); nn_list_item_term (&that.item); nn_list_term (&list); /* Iterating items. */ nn_list_init (&list); nn_list_item_init (&that.item); nn_list_insert (&list, &that.item, nn_list_end (&list)); list_item = nn_list_begin (&list); nn_assert (list_item == &that.item); item = nn_cont (list_item, struct item, item); nn_assert (item == &that); list_item = nn_list_end (&list); nn_assert (list_item == NULL); list_item = nn_list_prev (&list, &that.item); nn_assert (list_item == NULL); list_item = nn_list_next (&list, &that.item); nn_assert (list_item == NULL); rc = nn_list_empty (&list); nn_assert (rc == 0); nn_list_erase (&list, &that.item); nn_list_item_term (&that.item); nn_list_term (&list); /* Appending items. */ nn_list_init (&list); nn_list_item_init (&that.item); nn_list_item_init (&other.item); nn_list_insert (&list, &that.item, nn_list_end (&list)); nn_list_insert (&list, &other.item, nn_list_end (&list)); list_item = nn_list_begin (&list); nn_assert (list_item == &that.item); list_item = nn_list_next (&list, list_item); nn_assert (list_item == &other.item); nn_list_erase (&list, &that.item); nn_list_erase (&list, &other.item); nn_list_item_term (&that.item); nn_list_item_term (&other.item); nn_list_term (&list); /* Prepending items. */ nn_list_init (&list); nn_list_item_init (&that.item); nn_list_item_init (&other.item); nn_list_insert (&list, &that.item, nn_list_begin (&list)); nn_list_insert (&list, &other.item, nn_list_begin (&list)); list_item = nn_list_begin (&list); nn_assert (list_item == &other.item); list_item = nn_list_next (&list, list_item); nn_assert (list_item == &that.item); nn_list_erase (&list, &that.item); nn_list_erase (&list, &other.item); nn_list_item_term (&that.item); nn_list_item_term (&other.item); nn_list_term (&list); return 0; } nanomsg-0.8-beta/tests/msg.c0000664000175000017500000000713312623652600016742 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "testutil.h" #include #define SOCKET_ADDRESS "inproc://a" #define SOCKET_ADDRESS_TCP "tcp://127.0.0.1:5557" char longdata[1 << 20]; int main () { int rc; int sb; int sc; unsigned char *buf1, *buf2; int i; struct nn_iovec iov; struct nn_msghdr hdr; sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); buf1 = nn_allocmsg (256, 0); alloc_assert (buf1); for (i = 0; i != 256; ++i) buf1 [i] = (unsigned char) i; rc = nn_send (sc, &buf1, NN_MSG, 0); errno_assert (rc >= 0); nn_assert (rc == 256); buf2 = NULL; rc = nn_recv (sb, &buf2, NN_MSG, 0); errno_assert (rc >= 0); nn_assert (rc == 256); nn_assert (buf2); for (i = 0; i != 256; ++i) nn_assert (buf2 [i] == (unsigned char) i); rc = nn_freemsg (buf2); errno_assert (rc == 0); buf1 = nn_allocmsg (256, 0); alloc_assert (buf1); for (i = 0; i != 256; ++i) buf1 [i] = (unsigned char) i; iov.iov_base = &buf1; iov.iov_len = NN_MSG; memset (&hdr, 0, sizeof (hdr)); hdr.msg_iov = &iov; hdr.msg_iovlen = 1; rc = nn_sendmsg (sc, &hdr, 0); errno_assert (rc >= 0); nn_assert (rc == 256); buf2 = NULL; iov.iov_base = &buf2; iov.iov_len = NN_MSG; memset (&hdr, 0, sizeof (hdr)); hdr.msg_iov = &iov; hdr.msg_iovlen = 1; rc = nn_recvmsg (sb, &hdr, 0); errno_assert (rc >= 0); nn_assert (rc == 256); nn_assert (buf2); for (i = 0; i != 256; ++i) nn_assert (buf2 [i] == (unsigned char) i); rc = nn_freemsg (buf2); errno_assert (rc == 0); test_close (sc); test_close (sb); /* Test receiving of large message */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS_TCP); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS_TCP); for (i = 0; i < (int) sizeof (longdata); ++i) longdata[i] = '0' + (i % 10); longdata [sizeof (longdata) - 1] = 0; test_send (sb, longdata); rc = nn_recv (sc, &buf2, NN_MSG, 0); errno_assert (rc >= 0); nn_assert (rc == sizeof (longdata) - 1); nn_assert (buf2); for (i = 0; i < (int) sizeof (longdata) - 1; ++i) nn_assert (buf2 [i] == longdata [i]); rc = nn_freemsg (buf2); errno_assert (rc == 0); test_close (sc); test_close (sb); return 0; } nanomsg-0.8-beta/tests/pair.c0000664000175000017500000000312612623652600017105 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "testutil.h" #define SOCKET_ADDRESS "inproc://a" int main () { int sb; int sc; sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); test_send (sc, "ABC"); test_recv (sb, "ABC"); test_send (sb, "DEF"); test_recv (sc, "DEF"); test_close (sc); test_close (sb); return 0; } nanomsg-0.8-beta/tests/pipeline.c0000664000175000017500000000470312623652600017761 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "../src/nn.h" #include "../src/pipeline.h" #include "testutil.h" #define SOCKET_ADDRESS "inproc://a" int main () { int push1; int push2; int pull1; int pull2; /* Test fan-out. */ push1 = test_socket (AF_SP, NN_PUSH); test_bind (push1, SOCKET_ADDRESS); pull1 = test_socket (AF_SP, NN_PULL); test_connect (pull1, SOCKET_ADDRESS); pull2 = test_socket (AF_SP, NN_PULL); test_connect (pull2, SOCKET_ADDRESS); /* Wait till both connections are established to get messages spread evenly between the two pull sockets. */ nn_sleep (10); test_send (push1, "ABC"); test_send (push1, "DEF"); test_recv (pull1, "ABC"); test_recv (pull2, "DEF"); test_close (push1); test_close (pull1); test_close (pull2); /* Test fan-in. */ pull1 = test_socket (AF_SP, NN_PULL); test_bind (pull1, SOCKET_ADDRESS); push1 = test_socket (AF_SP, NN_PUSH); test_connect (push1, SOCKET_ADDRESS); push2 = test_socket (AF_SP, NN_PUSH); test_connect (push2, SOCKET_ADDRESS); test_send (push1, "ABC"); test_send (push2, "DEF"); test_recv (pull1, "ABC"); test_recv (pull1, "DEF"); test_close (pull1); test_close (push1); test_close (push2); return 0; } nanomsg-0.8-beta/tests/poll.c0000664000175000017500000001253112623652600017120 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "../src/inproc.h" #include "testutil.h" #include "../src/utils/attr.h" #include "../src/utils/thread.c" #if defined NN_HAVE_WINDOWS #include "../src/utils/win.h" #else #include #endif /* Test of polling via NN_SNDFD/NN_RCVFD mechanism. */ #define SOCKET_ADDRESS "inproc://a" int sc; void routine1 (NN_UNUSED void *arg) { nn_sleep (10); test_send (sc, "ABC"); } void routine2 (NN_UNUSED void *arg) { nn_sleep (10); nn_term (); } #define NN_IN 1 #define NN_OUT 2 int getevents (int s, int events, int timeout) { int rc; fd_set pollset; #if defined NN_HAVE_WINDOWS SOCKET rcvfd; SOCKET sndfd; #else int rcvfd; int sndfd; int maxfd; #endif size_t fdsz; struct timeval tv; int revents; #if !defined NN_HAVE_WINDOWS maxfd = 0; #endif FD_ZERO (&pollset); if (events & NN_IN) { fdsz = sizeof (rcvfd); rc = nn_getsockopt (s, NN_SOL_SOCKET, NN_RCVFD, (char*) &rcvfd, &fdsz); errno_assert (rc == 0); nn_assert (fdsz == sizeof (rcvfd)); FD_SET (rcvfd, &pollset); #if !defined NN_HAVE_WINDOWS if (rcvfd + 1 > maxfd) maxfd = rcvfd + 1; #endif } if (events & NN_OUT) { fdsz = sizeof (sndfd); rc = nn_getsockopt (s, NN_SOL_SOCKET, NN_SNDFD, (char*) &sndfd, &fdsz); errno_assert (rc == 0); nn_assert (fdsz == sizeof (sndfd)); FD_SET (sndfd, &pollset); #if !defined NN_HAVE_WINDOWS if (sndfd + 1 > maxfd) maxfd = sndfd + 1; #endif } if (timeout >= 0) { tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout % 1000) * 1000; } #if defined NN_HAVE_WINDOWS rc = select (0, &pollset, NULL, NULL, timeout < 0 ? NULL : &tv); wsa_assert (rc != SOCKET_ERROR); #else rc = select (maxfd, &pollset, NULL, NULL, timeout < 0 ? NULL : &tv); errno_assert (rc >= 0); #endif revents = 0; if ((events & NN_IN) && FD_ISSET (rcvfd, &pollset)) revents |= NN_IN; if ((events & NN_OUT) && FD_ISSET (sndfd, &pollset)) revents |= NN_OUT; return revents; } int main () { int rc; int sb; char buf [3]; struct nn_thread thread; struct nn_pollfd pfd [2]; /* Test nn_poll() function. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); test_send (sc, "ABC"); nn_sleep (100); pfd [0].fd = sb; pfd [0].events = NN_POLLIN | NN_POLLOUT; pfd [1].fd = sc; pfd [1].events = NN_POLLIN | NN_POLLOUT; rc = nn_poll (pfd, 2, -1); errno_assert (rc >= 0); nn_assert (rc == 2); nn_assert (pfd [0].revents == (NN_POLLIN | NN_POLLOUT)); nn_assert (pfd [1].revents == NN_POLLOUT); test_close (sc); test_close (sb); /* Create a simple topology. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); /* Check the initial state of the socket. */ rc = getevents (sb, NN_IN | NN_OUT, 1000); nn_assert (rc == NN_OUT); /* Poll for IN when there's no message available. The call should time out. */ rc = getevents (sb, NN_IN, 10); nn_assert (rc == 0); /* Send a message and start polling. This time IN event should be signaled. */ test_send (sc, "ABC"); rc = getevents (sb, NN_IN, 1000); nn_assert (rc == NN_IN); /* Receive the message and make sure that IN is no longer signaled. */ test_recv (sb, "ABC"); rc = getevents (sb, NN_IN, 10); nn_assert (rc == 0); /* Check signalling from a different thread. */ nn_thread_init (&thread, routine1, NULL); rc = getevents (sb, NN_IN, 1000); nn_assert (rc == NN_IN); test_recv (sb, "ABC"); nn_thread_term (&thread); /* Check terminating the library from a different thread. */ nn_thread_init (&thread, routine2, NULL); rc = getevents (sb, NN_IN, 1000); nn_assert (rc == NN_IN); rc = nn_recv (sb, buf, sizeof (buf), 0); nn_assert (rc < 0 && nn_errno () == ETERM); nn_thread_term (&thread); /* Clean up. */ test_close (sc); test_close (sb); return 0; } nanomsg-0.8-beta/tests/prio.c0000664000175000017500000000723412623652600017127 0ustar00travistravis00000000000000/* Copyright (c) 2013-2014 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "../src/nn.h" #include "../src/pipeline.h" #include "testutil.h" #define SOCKET_ADDRESS_A "inproc://a" #define SOCKET_ADDRESS_B "inproc://b" int main () { int rc; int push1; int push2; int pull1; int pull2; int sndprio; int rcvprio; /* Test send priorities. */ pull1 = test_socket (AF_SP, NN_PULL); test_bind (pull1, SOCKET_ADDRESS_A); pull2 = test_socket (AF_SP, NN_PULL); test_bind (pull2, SOCKET_ADDRESS_B); push1 = test_socket (AF_SP, NN_PUSH); sndprio = 1; rc = nn_setsockopt (push1, NN_SOL_SOCKET, NN_SNDPRIO, &sndprio, sizeof (sndprio)); errno_assert (rc == 0); test_connect (push1, SOCKET_ADDRESS_A); sndprio = 2; rc = nn_setsockopt (push1, NN_SOL_SOCKET, NN_SNDPRIO, &sndprio, sizeof (sndprio)); errno_assert (rc == 0); test_connect (push1, SOCKET_ADDRESS_B); test_send (push1, "ABC"); test_send (push1, "DEF"); test_recv (pull1, "ABC"); test_recv (pull1, "DEF"); test_close (pull1); test_close (push1); test_close (pull2); /* Test receive priorities. */ push1 = test_socket (AF_SP, NN_PUSH); test_bind (push1, SOCKET_ADDRESS_A); push2 = test_socket (AF_SP, NN_PUSH); test_bind (push2, SOCKET_ADDRESS_B); pull1 = test_socket (AF_SP, NN_PULL); rcvprio = 2; rc = nn_setsockopt (pull1, NN_SOL_SOCKET, NN_RCVPRIO, &rcvprio, sizeof (rcvprio)); errno_assert (rc == 0); test_connect (pull1, SOCKET_ADDRESS_A); rcvprio = 1; rc = nn_setsockopt (pull1, NN_SOL_SOCKET, NN_RCVPRIO, &rcvprio, sizeof (rcvprio)); errno_assert (rc == 0); test_connect (pull1, SOCKET_ADDRESS_B); test_send (push1, "ABC"); test_send (push2, "DEF"); nn_sleep (100); test_recv (pull1, "DEF"); test_recv (pull1, "ABC"); test_close (pull1); test_close (push2); test_close (push1); /* Test removing a pipe from the list. */ push1 = test_socket (AF_SP, NN_PUSH); test_bind (push1, SOCKET_ADDRESS_A); pull1 = test_socket (AF_SP, NN_PULL); test_connect (pull1, SOCKET_ADDRESS_A); test_send (push1, "ABC"); test_recv (pull1, "ABC"); test_close (pull1); rc = nn_send (push1, "ABC", 3, NN_DONTWAIT); nn_assert (rc == -1 && nn_errno() == EAGAIN); pull1 = test_socket (AF_SP, NN_PULL); test_connect (pull1, SOCKET_ADDRESS_A); test_send (push1, "ABC"); test_recv (pull1, "ABC"); test_close (pull1); test_close (push1); return 0; } nanomsg-0.8-beta/tests/pubsub.c0000664000175000017500000000600312623652600017447 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pubsub.h" #include "testutil.h" #define SOCKET_ADDRESS "inproc://a" int main () { int rc; int pub1; int pub2; int sub1; int sub2; char buf [8]; size_t sz; pub1 = test_socket (AF_SP, NN_PUB); test_bind (pub1, SOCKET_ADDRESS); sub1 = test_socket (AF_SP, NN_SUB); rc = nn_setsockopt (sub1, NN_SUB, NN_SUB_SUBSCRIBE, "", 0); errno_assert (rc == 0); sz = sizeof (buf); rc = nn_getsockopt (sub1, NN_SUB, NN_SUB_SUBSCRIBE, buf, &sz); nn_assert (rc == -1 && nn_errno () == ENOPROTOOPT); test_connect (sub1, SOCKET_ADDRESS); sub2 = test_socket (AF_SP, NN_SUB); rc = nn_setsockopt (sub2, NN_SUB, NN_SUB_SUBSCRIBE, "", 0); errno_assert (rc == 0); test_connect (sub2, SOCKET_ADDRESS); /* Wait till connections are established to prevent message loss. */ nn_sleep (10); test_send (pub1, "0123456789012345678901234567890123456789"); test_recv (sub1, "0123456789012345678901234567890123456789"); test_recv (sub2, "0123456789012345678901234567890123456789"); test_close (pub1); test_close (sub1); test_close (sub2); /* Check receiving messages from two publishers. */ sub1 = test_socket (AF_SP, NN_SUB); rc = nn_setsockopt (sub1, NN_SUB, NN_SUB_SUBSCRIBE, "", 0); errno_assert (rc == 0); test_bind (sub1, SOCKET_ADDRESS); pub1 = test_socket (AF_SP, NN_PUB); test_connect (pub1, SOCKET_ADDRESS); pub2 = test_socket (AF_SP, NN_PUB); test_connect (pub2, SOCKET_ADDRESS); nn_sleep (100); test_send (pub1, "0123456789012345678901234567890123456789"); test_send (pub2, "0123456789012345678901234567890123456789"); test_recv (sub1, "0123456789012345678901234567890123456789"); test_recv (sub1, "0123456789012345678901234567890123456789"); test_close (pub2); test_close (pub1); test_close (sub1); return 0; } nanomsg-0.8-beta/tests/reqrep.c0000664000175000017500000001266612623652600017461 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/reqrep.h" #include "testutil.h" #define SOCKET_ADDRESS "inproc://test" int main () { int rc; int rep1; int rep2; int req1; int req2; int resend_ivl; char buf [7]; int timeo; /* Test req/rep with full socket types. */ rep1 = test_socket (AF_SP, NN_REP); test_bind (rep1, SOCKET_ADDRESS); req1 = test_socket (AF_SP, NN_REQ); test_connect (req1, SOCKET_ADDRESS); req2 = test_socket (AF_SP, NN_REQ); test_connect (req2, SOCKET_ADDRESS); /* Check invalid sequence of sends and recvs. */ rc = nn_send (rep1, "ABC", 3, 0); nn_assert (rc == -1 && nn_errno () == EFSM); rc = nn_recv (req1, buf, sizeof (buf), 0); nn_assert (rc == -1 && nn_errno () == EFSM); /* Check fair queueing the requests. */ test_send (req2, "ABC"); test_recv (rep1, "ABC"); test_send (rep1, "ABC"); test_recv (req2, "ABC"); test_send (req1, "ABC"); test_recv (rep1, "ABC"); test_send (rep1, "ABC"); test_recv (req1, "ABC"); test_close (rep1); test_close (req1); test_close (req2); /* Check load-balancing of requests. */ req1 = test_socket (AF_SP, NN_REQ); test_bind (req1, SOCKET_ADDRESS); rep1 = test_socket (AF_SP, NN_REP); test_connect (rep1, SOCKET_ADDRESS); rep2 = test_socket (AF_SP, NN_REP); test_connect (rep2, SOCKET_ADDRESS); test_send (req1, "ABC"); test_recv (rep1, "ABC"); test_send (rep1, "ABC"); test_recv (req1, "ABC"); test_send (req1, "ABC"); test_recv (rep2, "ABC"); test_send (rep2, "ABC"); test_recv (req1, "ABC"); test_close (rep2); test_close (rep1); test_close (req1); /* Test re-sending of the request. */ rep1 = test_socket (AF_SP, NN_REP); test_bind (rep1, SOCKET_ADDRESS); req1 = test_socket (AF_SP, NN_REQ); test_connect (req1, SOCKET_ADDRESS); resend_ivl = 100; rc = nn_setsockopt (req1, NN_REQ, NN_REQ_RESEND_IVL, &resend_ivl, sizeof (resend_ivl)); errno_assert (rc == 0); test_send (req1, "ABC"); test_recv (rep1, "ABC"); /* The following waits for request to be resent */ test_recv (rep1, "ABC"); test_close (req1); test_close (rep1); /* Check sending a request when the peer is not available. (It should be sent immediatelly when the peer comes online rather than relying on the resend algorithm. */ req1 = test_socket (AF_SP, NN_REQ); test_connect (req1, SOCKET_ADDRESS); test_send (req1, "ABC"); rep1 = test_socket (AF_SP, NN_REP); test_bind (rep1, SOCKET_ADDRESS); timeo = 200; rc = nn_setsockopt (rep1, NN_SOL_SOCKET, NN_RCVTIMEO, &timeo, sizeof (timeo)); errno_assert (rc == 0); test_recv (rep1, "ABC"); test_close (req1); test_close (rep1); /* Check removing socket request sent to (It should be sent immediatelly to other peer rather than relying on the resend algorithm). */ req1 = test_socket (AF_SP, NN_REQ); test_bind (req1, SOCKET_ADDRESS); rep1 = test_socket (AF_SP, NN_REP); test_connect (rep1, SOCKET_ADDRESS); rep2 = test_socket (AF_SP, NN_REP); test_connect (rep2, SOCKET_ADDRESS); timeo = 200; rc = nn_setsockopt (rep1, NN_SOL_SOCKET, NN_RCVTIMEO, &timeo, sizeof (timeo)); errno_assert (rc == 0); rc = nn_setsockopt (rep2, NN_SOL_SOCKET, NN_RCVTIMEO, &timeo, sizeof (timeo)); errno_assert (rc == 0); test_send (req1, "ABC"); /* We got request through rep1 */ test_recv (rep1, "ABC"); /* But instead replying we simulate crash */ test_close (rep1); /* The rep2 should get request immediately */ test_recv (rep2, "ABC"); /* Let's check it's delivered well */ test_send (rep2, "REPLY"); test_recv (req1, "REPLY"); test_close (req1); test_close (rep2); /* Test cancelling delayed request */ req1 = test_socket (AF_SP, NN_REQ); test_connect (req1, SOCKET_ADDRESS); test_send (req1, "ABC"); test_send (req1, "DEF"); rep1 = test_socket (AF_SP, NN_REP); test_bind (rep1, SOCKET_ADDRESS); timeo = 100; // rc = nn_setsockopt (rep1, NN_SOL_SOCKET, NN_RCVTIMEO, // &timeo, sizeof (timeo)); // errno_assert (rc == 0); test_recv (rep1, "DEF"); test_close (req1); test_close (rep1); return 0; } nanomsg-0.8-beta/tests/separation.c0000664000175000017500000000677312623652600020332 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik All rights reserved. Copyright (c) 2013 GoPivotal, Inc. 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 "../src/nn.h" #include "../src/pair.h" #include "../src/pipeline.h" #include "../src/inproc.h" #include "../src/ipc.h" #include "../src/tcp.h" #include "testutil.h" #define SOCKET_ADDRESS_INPROC "inproc://a" #define SOCKET_ADDRESS_IPC "ipc://test-separation.ipc" #define SOCKET_ADDRESS_TCP "tcp://127.0.0.1:5556" /* This test checks whether the library prevents interconnecting sockets between different non-compatible protocols. */ int main () { int rc; int pair; int pull; int timeo; /* Inproc: Bind first, connect second. */ pair = test_socket (AF_SP, NN_PAIR); test_bind (pair, SOCKET_ADDRESS_INPROC); pull = test_socket (AF_SP, NN_PULL); test_connect (pull, SOCKET_ADDRESS_INPROC); timeo = 100; test_setsockopt (pair, NN_SOL_SOCKET, NN_SNDTIMEO, &timeo, sizeof (timeo)); rc = nn_send (pair, "ABC", 3, 0); errno_assert (rc < 0 && nn_errno () == ETIMEDOUT); test_close (pull); test_close (pair); /* Inproc: Connect first, bind second. */ pull = test_socket (AF_SP, NN_PULL); test_connect (pull, SOCKET_ADDRESS_INPROC); pair = test_socket (AF_SP, NN_PAIR); test_bind (pair, SOCKET_ADDRESS_INPROC); timeo = 100; test_setsockopt (pair, NN_SOL_SOCKET, NN_SNDTIMEO, &timeo, sizeof (timeo)); rc = nn_send (pair, "ABC", 3, 0); errno_assert (rc < 0 && nn_errno () == ETIMEDOUT); test_close (pull); test_close (pair); #if !defined NN_HAVE_WINDOWS /* IPC */ pair = test_socket (AF_SP, NN_PAIR); test_bind (pair, SOCKET_ADDRESS_IPC); pull = test_socket (AF_SP, NN_PULL); test_connect (pull, SOCKET_ADDRESS_IPC); timeo = 100; test_setsockopt (pair, NN_SOL_SOCKET, NN_SNDTIMEO, &timeo, sizeof (timeo)); rc = nn_send (pair, "ABC", 3, 0); errno_assert (rc < 0 && nn_errno () == ETIMEDOUT); test_close (pull); test_close (pair); #endif /* TCP */ pair = test_socket (AF_SP, NN_PAIR); test_bind (pair, SOCKET_ADDRESS_TCP); pull = test_socket (AF_SP, NN_PULL); test_connect (pull, SOCKET_ADDRESS_TCP); timeo = 100; test_setsockopt (pair, NN_SOL_SOCKET, NN_SNDTIMEO, &timeo, sizeof (timeo)); rc = nn_send (pair, "ABC", 3, 0); errno_assert (rc < 0 && nn_errno () == ETIMEDOUT); test_close (pull); test_close (pair); return 0; } nanomsg-0.8-beta/tests/shutdown.c0000664000175000017500000000302112623652600020017 0ustar00travistravis00000000000000/* Copyright (c) 2013 GoPivotal, Inc. 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 "../src/nn.h" #include "../src/tcp.h" #include "../src/reqrep.h" #include "testutil.h" int main () { int s; int rc; int eid; /* Run endpoint shutdown and socket shutdown in parallel. */ s = test_socket (AF_SP, NN_REQ); eid = test_connect (s, "tcp://127.0.0.1:5590"); rc = nn_shutdown (s, eid); errno_assert (rc == 0); test_close (s); return 0; } nanomsg-0.8-beta/tests/survey.c0000664000175000017500000000670312623652600017513 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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 "../src/nn.h" #include "../src/survey.h" #include "testutil.h" #define SOCKET_ADDRESS "inproc://test" int main () { int rc; int surveyor; int respondent1; int respondent2; int respondent3; int deadline; char buf [7]; /* Test a simple survey with three respondents. */ surveyor = test_socket (AF_SP, NN_SURVEYOR); deadline = 500; rc = nn_setsockopt (surveyor, NN_SURVEYOR, NN_SURVEYOR_DEADLINE, &deadline, sizeof (deadline)); errno_assert (rc == 0); test_bind (surveyor, SOCKET_ADDRESS); respondent1 = test_socket (AF_SP, NN_RESPONDENT); test_connect (respondent1, SOCKET_ADDRESS); respondent2 = test_socket (AF_SP, NN_RESPONDENT); test_connect (respondent2, SOCKET_ADDRESS); respondent3 = test_socket (AF_SP, NN_RESPONDENT); test_connect (respondent3, SOCKET_ADDRESS); /* Check that attempt to recv with no survey pending is EFSM. */ rc = nn_recv (surveyor, buf, sizeof (buf), 0); errno_assert (rc == -1 && nn_errno () == EFSM); /* Send the survey. */ test_send (surveyor, "ABC"); /* First respondent answers. */ test_recv (respondent1, "ABC"); test_send (respondent1, "DEF"); /* Second respondent answers. */ test_recv (respondent2, "ABC"); test_send (respondent2, "DEF"); /* Surveyor gets the responses. */ test_recv (surveyor, "DEF"); test_recv (surveyor, "DEF"); /* There are no more responses. Surveyor hits the deadline. */ rc = nn_recv (surveyor, buf, sizeof (buf), 0); errno_assert (rc == -1 && nn_errno () == ETIMEDOUT); /* Third respondent answers (it have already missed the deadline). */ test_recv (respondent3, "ABC"); test_send (respondent3, "GHI"); /* Surveyor initiates new survey. */ test_send (surveyor, "ABC"); /* Check that stale response from third respondent is not delivered. */ rc = nn_recv (surveyor, buf, sizeof (buf), 0); errno_assert (rc == -1 && nn_errno () == ETIMEDOUT); /* Check that subsequent attempt to recv with no survey pending is EFSM. */ rc = nn_recv (surveyor, buf, sizeof (buf), 0); errno_assert (rc == -1 && nn_errno () == EFSM); test_close (surveyor); test_close (respondent1); test_close (respondent2); test_close (respondent3); return 0; } nanomsg-0.8-beta/tests/symbol.c0000664000175000017500000000375712623652600017471 0ustar00travistravis00000000000000/* Copyright (c) 2013 Evan Wies 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 "../src/utils/err.c" int main () { int i; struct nn_symbol_properties sym; int value; nn_assert (nn_symbol (-1, NULL) == NULL); nn_assert (nn_errno () == EINVAL); nn_assert (nn_symbol_info (-1, &sym, (int) sizeof (sym)) == 0); nn_assert (nn_symbol (2000, NULL) == NULL); nn_assert (nn_errno () == EINVAL); nn_assert (nn_symbol_info (2000, &sym, (int) sizeof (sym)) == 0); nn_assert (nn_symbol (6, &value) != NULL); nn_assert (value != 0); nn_assert (nn_symbol_info (6, &sym, (int) sizeof (sym)) == sizeof (sym)); for (i = 0; ; ++i) { const char* name = nn_symbol (i, &value); if (name == NULL) { nn_assert (nn_errno () == EINVAL); break; } } for (i = 0; ; ++i) { if (nn_symbol_info (i, &sym, sizeof (sym)) == 0) break; } return 0; } nanomsg-0.8-beta/tests/tcp.c0000664000175000017500000001650212623652600016742 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik All rights reserved. Copyright 2015 Garrett D'Amore 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 "../src/nn.h" #include "../src/pair.h" #include "../src/pubsub.h" #include "../src/tcp.h" #include "testutil.h" /* Tests TCP transport. */ #define SOCKET_ADDRESS "tcp://127.0.0.1:5555" int sc; int main () { int rc; int sb; int i; int opt; size_t sz; int s1, s2; void * dummy_buf; /* Try closing bound but unconnected socket. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); test_close (sb); /* Try closing a TCP socket while it not connected. At the same time test specifying the local address for the connection. */ sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, "tcp://127.0.0.1;127.0.0.1:5555"); test_close (sc); /* Open the socket anew. */ sc = test_socket (AF_SP, NN_PAIR); /* Check NODELAY socket option. */ sz = sizeof (opt); rc = nn_getsockopt (sc, NN_TCP, NN_TCP_NODELAY, &opt, &sz); errno_assert (rc == 0); nn_assert (sz == sizeof (opt)); nn_assert (opt == 0); opt = 2; rc = nn_setsockopt (sc, NN_TCP, NN_TCP_NODELAY, &opt, sizeof (opt)); nn_assert (rc < 0 && nn_errno () == EINVAL); opt = 1; rc = nn_setsockopt (sc, NN_TCP, NN_TCP_NODELAY, &opt, sizeof (opt)); errno_assert (rc == 0); sz = sizeof (opt); rc = nn_getsockopt (sc, NN_TCP, NN_TCP_NODELAY, &opt, &sz); errno_assert (rc == 0); nn_assert (sz == sizeof (opt)); nn_assert (opt == 1); /* Try using invalid address strings. */ rc = nn_connect (sc, "tcp://*:"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "tcp://*:1000000"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "tcp://*:some_port"); nn_assert (rc < 0); rc = nn_connect (sc, "tcp://eth10000;127.0.0.1:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == ENODEV); rc = nn_connect (sc, "tcp://127.0.0.1"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_bind (sc, "tcp://127.0.0.1:"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_bind (sc, "tcp://127.0.0.1:1000000"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_bind (sc, "tcp://eth10000:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == ENODEV); rc = nn_connect (sc, "tcp://:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "tcp://-hostname:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "tcp://abc.123.---.#:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "tcp://[::1]:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "tcp://abc.123.:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "tcp://abc...123:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "tcp://.123:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); /* Connect correctly. Do so before binding the peer socket. */ test_connect (sc, SOCKET_ADDRESS); /* Leave enough time for at least on re-connect attempt. */ nn_sleep (200); sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); /* Ping-pong test. */ for (i = 0; i != 100; ++i) { test_send (sc, "ABC"); test_recv (sb, "ABC"); test_send (sb, "DEF"); test_recv (sc, "DEF"); } /* Batch transfer test. */ for (i = 0; i != 100; ++i) { test_send (sc, "0123456789012345678901234567890123456789"); } for (i = 0; i != 100; ++i) { test_recv (sb, "0123456789012345678901234567890123456789"); } test_close (sc); test_close (sb); /* Test whether connection rejection is handled decently. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); s1 = test_socket (AF_SP, NN_PAIR); test_connect (s1, SOCKET_ADDRESS); s2 = test_socket (AF_SP, NN_PAIR); test_connect (s2, SOCKET_ADDRESS); nn_sleep (100); test_close (s2); test_close (s1); test_close (sb); /* Test two sockets binding to the same address. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); s1 = test_socket (AF_SP, NN_PAIR); test_bind (s1, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); nn_sleep (100); test_send (sb, "ABC"); test_recv (sc, "ABC"); test_close (sb); test_send (s1, "ABC"); test_recv (sc, "ABC"); test_close (sc); test_close (s1); /* Test NN_RCVMAXSIZE limit */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); s1 = test_socket (AF_SP, NN_PAIR); test_connect (s1, SOCKET_ADDRESS); opt = 4; rc = nn_setsockopt (sb, NN_SOL_SOCKET, NN_RCVMAXSIZE, &opt, sizeof (opt)); nn_assert (rc == 0); nn_sleep (100); test_send (s1, "ABC"); test_recv (sb, "ABC"); test_send (s1, "0123456789012345678901234567890123456789"); rc = nn_recv (sb, &dummy_buf, NN_MSG, NN_DONTWAIT); nn_assert (rc < 0); errno_assert (nn_errno () == EAGAIN); test_close (sb); test_close (s1); /* Test that NN_RCVMAXSIZE can be -1, but not lower */ sb = test_socket (AF_SP, NN_PAIR); opt = -1; rc = nn_setsockopt (sb, NN_SOL_SOCKET, NN_RCVMAXSIZE, &opt, sizeof (opt)); nn_assert (rc >= 0); opt = -2; rc = nn_setsockopt (sb, NN_SOL_SOCKET, NN_RCVMAXSIZE, &opt, sizeof (opt)); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); test_close (sb); /* Test closing a socket that is waiting to bind. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); nn_sleep (100); s1 = test_socket (AF_SP, NN_PAIR); test_bind (s1, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); nn_sleep (100); test_send (sb, "ABC"); test_recv (sc, "ABC"); test_close (s1); test_send (sb, "ABC"); test_recv (sc, "ABC"); test_close (sb); test_close (sc); return 0; } nanomsg-0.8-beta/tests/tcp_shutdown.c0000664000175000017500000000674712623652600020707 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "../src/pubsub.h" #include "../src/pipeline.h" #include "../src/tcp.h" #include "testutil.h" #include "../src/utils/attr.h" #include "../src/utils/thread.c" #include "../src/utils/atomic.c" /* Stress test the TCP transport. */ #define THREAD_COUNT 100 #define TEST2_THREAD_COUNT 10 #define MESSAGES_PER_THREAD 10 #define TEST_LOOPS 10 #define SOCKET_ADDRESS "tcp://127.0.0.1:5557" struct nn_atomic active; static void routine (NN_UNUSED void *arg) { int s; s = nn_socket (AF_SP, NN_SUB); if (s < 0 && nn_errno () == EMFILE) return; errno_assert (s >= 0); test_connect (s, SOCKET_ADDRESS); test_close (s); } static void routine2 (NN_UNUSED void *arg) { int s; int i; int ms; s = test_socket (AF_SP, NN_PULL); for (i = 0; i < 10; ++i) { test_connect (s, SOCKET_ADDRESS); } ms = 2000; test_setsockopt (s, NN_SOL_SOCKET, NN_RCVTIMEO, &ms, sizeof (ms)); for (i = 0; i < MESSAGES_PER_THREAD; ++i) { test_recv (s, "hello"); } test_close (s); nn_atomic_dec(&active, 1); } int main () { int sb; int i; int j; struct nn_thread threads [THREAD_COUNT]; /* Stress the shutdown algorithm. */ #if defined(SIGPIPE) && defined(SIG_IGN) signal (SIGPIPE, SIG_IGN); #endif sb = test_socket (AF_SP, NN_PUB); test_bind (sb, SOCKET_ADDRESS); for (j = 0; j != TEST_LOOPS; ++j) { for (i = 0; i != THREAD_COUNT; ++i) nn_thread_init (&threads [i], routine, NULL); for (i = 0; i != THREAD_COUNT; ++i) { nn_thread_term (&threads [i]); } } test_close (sb); /* Test race condition of sending message while socket shutting down */ sb = test_socket (AF_SP, NN_PUSH); test_bind (sb, SOCKET_ADDRESS); for (j = 0; j != TEST_LOOPS; ++j) { int ms; for (i = 0; i != TEST2_THREAD_COUNT; ++i) nn_thread_init (&threads [i], routine2, &threads[i]); nn_atomic_init(&active, TEST2_THREAD_COUNT); ms = 2000; test_setsockopt (sb, NN_SOL_SOCKET, NN_SNDTIMEO, &ms, sizeof (ms)); while (active.n) { (void) nn_send (sb, "hello", 5, NN_DONTWAIT); } for (i = 0; i != TEST2_THREAD_COUNT; ++i) nn_thread_term (&threads [i]); nn_atomic_term(&active); } test_close (sb); return 0; } nanomsg-0.8-beta/tests/tcpmux.c0000664000175000017500000000355612623652600017501 0ustar00travistravis00000000000000/* Copyright (c) 2014 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "../src/tcpmux.h" #include "testutil.h" /* Tests TCPMUX transport. */ int sc; int main () { #if !defined NN_HAVE_WINDOWS int rc; int sb; int sc; int i; /* First, start tcpmux daemon. */ rc = nn_tcpmuxd (5555); errno_assert (rc == 0); /* Create a connection. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, "tcpmux://*:5555/foo"); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, "tcpmux://127.0.0.1:5555/foo"); /* Ping-pong test. */ for (i = 0; i != 100; ++i) { test_send (sc, "ABC"); test_recv (sb, "ABC"); } /* Cleanup. */ test_close (sc); test_close (sb); #endif return 0; } nanomsg-0.8-beta/tests/term.c0000664000175000017500000000454712623652600017131 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "../src/utils/thread.c" #include "testutil.h" static void worker (NN_UNUSED void *arg) { int rc; int s; char buf [3]; /* Test socket. */ s = test_socket (AF_SP, NN_PAIR); /* Launch blocking function to check that it will be unblocked once nn_term() is called from the main thread. */ rc = nn_recv (s, buf, sizeof (buf), 0); nn_assert (rc == -1 && nn_errno () == ETERM); /* Check that all subsequent operations fail in synchronous manner. */ rc = nn_recv (s, buf, sizeof (buf), 0); nn_assert (rc == -1 && nn_errno () == ETERM); test_close (s); } int main () { int rc; int s; struct nn_thread thread; /* Close the socket with no associated endpoints. */ s = test_socket (AF_SP, NN_PAIR); test_close (s); /* Test nn_term() before nn_close(). */ nn_thread_init (&thread, worker, NULL); nn_sleep (100); nn_term (); /* Check that it's not possible to create new sockets after nn_term(). */ rc = nn_socket (AF_SP, NN_PAIR); nn_assert (rc == -1); errno_assert (nn_errno () == ETERM); /* Wait till worker thread terminates. */ nn_thread_term (&thread); return 0; } nanomsg-0.8-beta/tests/timeo.c0000664000175000017500000000413312623652600017266 0ustar00travistravis00000000000000/* Copyright (c) 2012 Martin Sustrik 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 "../src/nn.h" #include "../src/pair.h" #include "testutil.h" #include "../src/utils/stopwatch.c" int main () { int rc; int s; int timeo; char buf [3]; struct nn_stopwatch stopwatch; uint64_t elapsed; s = test_socket (AF_SP, NN_PAIR); timeo = 100; rc = nn_setsockopt (s, NN_SOL_SOCKET, NN_RCVTIMEO, &timeo, sizeof (timeo)); errno_assert (rc == 0); nn_stopwatch_init (&stopwatch); rc = nn_recv (s, buf, sizeof (buf), 0); elapsed = nn_stopwatch_term (&stopwatch); errno_assert (rc < 0 && nn_errno () == ETIMEDOUT); time_assert (elapsed, 100000); timeo = 100; rc = nn_setsockopt (s, NN_SOL_SOCKET, NN_SNDTIMEO, &timeo, sizeof (timeo)); errno_assert (rc == 0); nn_stopwatch_init (&stopwatch); rc = nn_send (s, "ABC", 3, 0); elapsed = nn_stopwatch_term (&stopwatch); errno_assert (rc < 0 && nn_errno () == ETIMEDOUT); time_assert (elapsed, 100000); test_close (s); return 0; } nanomsg-0.8-beta/tests/trie.c0000664000175000017500000002003412623652600017112 0ustar00travistravis00000000000000/* Copyright (c) 2013 Martin Sustrik 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 "../src/protocols/pubsub/trie.c" #include "../src/utils/alloc.c" #include "../src/utils/err.c" #include int main () { int rc; struct nn_trie trie; /* Try matching with an empty trie. */ nn_trie_init (&trie); rc = nn_trie_match (&trie, (const uint8_t*) "", 0); nn_assert (rc == 0); rc = nn_trie_match (&trie, (const uint8_t*) "ABC", 3); nn_assert (rc == 0); nn_trie_term (&trie); /* Try matching with "all" subscription. */ nn_trie_init (&trie); rc = nn_trie_subscribe (&trie, (const uint8_t*) "", 0); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "", 0); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "ABC", 3); nn_assert (rc == 1); nn_trie_term (&trie); /* Try some simple matching. */ nn_trie_init (&trie); rc = nn_trie_subscribe (&trie, (const uint8_t*) "ABC", 3); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "DEF", 3); nn_assert (rc == 0); rc = nn_trie_match (&trie, (const uint8_t*) "AB", 2); nn_assert (rc == 0); rc = nn_trie_match (&trie, (const uint8_t*) "ABC", 3); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "ABCDE", 5); nn_assert (rc == 1); nn_trie_term (&trie); /* Try a long subcsription. */ nn_trie_init (&trie); rc = nn_trie_subscribe (&trie, (const uint8_t*) "01234567890123456789012345678901234", 35); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "", 0); nn_assert (rc == 0); rc = nn_trie_match (&trie, (const uint8_t*) "012456789", 10); nn_assert (rc == 0); rc = nn_trie_match (&trie, (const uint8_t*) "012345678901234567", 18); nn_assert (rc == 0); rc = nn_trie_match (&trie, (const uint8_t*) "01234567890123456789012345678901234", 35); nn_assert (rc == 1); nn_trie_term (&trie); /* Try matching with a sparse node involved. */ nn_trie_init (&trie); rc = nn_trie_subscribe (&trie, (const uint8_t*) "ABC", 3); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "ADE", 3); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "A", 1); nn_assert (rc == 0); rc = nn_trie_match (&trie, (const uint8_t*) "AD", 2); nn_assert (rc == 0); nn_trie_term (&trie); /* Try matching with a dense node involved. */ nn_trie_init (&trie); rc = nn_trie_subscribe (&trie, (const uint8_t*) "A", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "B", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "C", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "0", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "E", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "F", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "1", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "@", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "b", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "f", 1); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "0", 1); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "A", 1); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "f", 1); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "000", 3); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "a", 1); nn_assert (rc == 0); rc = nn_trie_match (&trie, (const uint8_t*) "c", 1); nn_assert (rc == 0); nn_trie_term (&trie); /* Check prefix splitting and compaction. */ nn_trie_init (&trie); rc = nn_trie_subscribe (&trie, (const uint8_t*) "ABCD", 4); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "AB", 2); nn_assert (rc == 1); rc = nn_trie_unsubscribe (&trie, (const uint8_t*) "AB", 2); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "AB", 2); nn_assert (rc == 0); rc = nn_trie_match (&trie, (const uint8_t*) "ABCDEF", 6); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "ABEF", 4); nn_assert (rc == 1); rc = nn_trie_unsubscribe (&trie, (const uint8_t*) "ABCD", 4); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "ABCD", 4); nn_assert (rc == 0); rc = nn_trie_match (&trie, (const uint8_t*) "ABEF", 4); nn_assert (rc == 1); nn_trie_term (&trie); /* Check whether there's no problem with removing all subscriptions. */ nn_trie_init (&trie); rc = nn_trie_subscribe (&trie, (const uint8_t*) "A", 1); nn_assert (rc == 1); rc = nn_trie_unsubscribe (&trie, (const uint8_t*) "A", 1); nn_assert (rc == 1); rc = nn_trie_match (&trie, (const uint8_t*) "", 0); nn_assert (rc == 0); rc = nn_trie_match (&trie, (const uint8_t*) "A", 1); nn_assert (rc == 0); nn_trie_term (&trie); /* Check converting from sparse node to dense node and vice versa. */ nn_trie_init (&trie); rc = nn_trie_subscribe (&trie, (const uint8_t*) "A", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "B", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "C", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "0", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "E", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "F", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "1", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "@", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "b", 1); nn_assert (rc == 1); rc = nn_trie_subscribe (&trie, (const uint8_t*) "f", 1); nn_assert (rc == 1); rc = nn_trie_unsubscribe (&trie, (const uint8_t*) "0", 1); nn_assert (rc == 1); rc = nn_trie_unsubscribe (&trie, (const uint8_t*) "f", 1); nn_assert (rc == 1); rc = nn_trie_unsubscribe (&trie, (const uint8_t*) "E", 1); nn_assert (rc == 1); rc = nn_trie_unsubscribe (&trie, (const uint8_t*) "B", 1); nn_assert (rc == 1); rc = nn_trie_unsubscribe (&trie, (const uint8_t*) "A", 1); nn_assert (rc == 1); rc = nn_trie_unsubscribe (&trie, (const uint8_t*) "1", 1); nn_assert (rc == 1); rc = nn_trie_unsubscribe (&trie, (const uint8_t*) "@", 1); nn_assert (rc == 1); rc = nn_trie_unsubscribe (&trie, (const uint8_t*) "F", 1); nn_assert (rc == 1); rc = nn_trie_unsubscribe (&trie, (const uint8_t*) "C", 1); nn_assert (rc == 1); rc = nn_trie_unsubscribe (&trie, (const uint8_t*) "b", 1); nn_assert (rc == 1); nn_trie_term (&trie); return 0; } nanomsg-0.8-beta/tests/ws.c0000664000175000017500000001363312623652600016607 0ustar00travistravis00000000000000/* Copyright (c) 2012 250bpm s.r.o. All rights reserved. Copyright (c) 2014 Wirebird Labs LLC. All rights reserved. Copyright 2015 Garrett D'Amore 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 "../src/nn.h" #include "../src/pair.h" #include "../src/ws.h" #include "../src/utils/int.h" #include "testutil.h" #define SOCKET_ADDRESS "ws://127.0.0.1:5555" /* Basic tests for WebSocket transport. */ /* test_text() verifies that we drop messages properly when sending invalid UTF-8, but not when we send valid data. */ void test_text() { int sb; int sc; int opt; uint8_t bad[20]; /* Negative testing... bad UTF-8 data for text. */ sb = test_socket (AF_SP, NN_PAIR); sc = test_socket (AF_SP, NN_PAIR); /* Wait for connects to establish. */ nn_sleep (200); opt = NN_WS_MSG_TYPE_TEXT; test_setsockopt(sb, NN_WS, NN_WS_MSG_TYPE, &opt, sizeof (opt)); opt = NN_WS_MSG_TYPE_TEXT; test_setsockopt(sc, NN_WS, NN_WS_MSG_TYPE, &opt, sizeof (opt)); opt = 500; test_setsockopt(sb, NN_SOL_SOCKET, NN_RCVTIMEO, &opt, sizeof (opt)); test_bind (sb, SOCKET_ADDRESS); test_connect (sc, SOCKET_ADDRESS); test_send (sc, "GOOD"); test_recv (sb, "GOOD"); /* and the bad ... */ strcpy((char *)bad, "BAD."); bad[2] = (char)0xDD; test_send (sc, (char *)bad); /* Make sure we dropped the frame. */ test_drop (sb, ETIMEDOUT); } int main () { int rc; int sb; int sc; int opt; size_t sz; int i; /* Try closing bound but unconnected socket. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, "ws://*:5555"); test_close (sb); /* Try closing a TCP socket while it not connected. At the same time test specifying the local address for the connection. */ sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, "ws://127.0.0.1:5555"); test_close (sc); /* Open the socket anew. */ sc = test_socket (AF_SP, NN_PAIR); /* Check socket options. */ sz = sizeof (opt); rc = nn_getsockopt (sc, NN_WS, NN_WS_MSG_TYPE, &opt, &sz); errno_assert (rc == 0); nn_assert (sz == sizeof (opt)); nn_assert (opt == NN_WS_MSG_TYPE_BINARY); #if 0 //opt = 100; //sz = sizeof (opt); //rc = nn_getsockopt (sc, NN_WS, NN_WS_HANDSHAKE_TIMEOUT, &opt, &sz); //errno_assert (rc == 0); //nn_assert (sz == sizeof (opt)); //nn_assert (opt == 100); #endif /* Default port 80 should be assumed if not explicitly declared. */ rc = nn_connect (sc, "ws://127.0.0.1"); errno_assert (rc >= 0); /* Try using invalid address strings. */ rc = nn_connect (sc, "ws://*:"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://*:1000000"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://*:some_port"); nn_assert (rc < 0); rc = nn_connect (sc, "ws://eth10000;127.0.0.1:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == ENODEV); rc = nn_bind (sc, "ws://127.0.0.1:"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_bind (sc, "ws://127.0.0.1:1000000"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_bind (sc, "ws://eth10000:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == ENODEV); rc = nn_connect (sc, "ws://:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://-hostname:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://abc.123.---.#:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://[::1]:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://abc.123.:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://abc...123:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://.123:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); test_close (sc); nn_sleep (200); sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, SOCKET_ADDRESS); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, SOCKET_ADDRESS); /* Leave enough time for connection establishment. */ nn_sleep (200); /* Ping-pong test. */ for (i = 0; i != 100; ++i) { test_send (sc, "ABC"); test_recv (sb, "ABC"); test_send (sb, "DEF"); test_recv (sc, "DEF"); } /* Batch transfer test. */ for (i = 0; i != 100; ++i) { test_send (sc, "0123456789012345678901234567890123456789"); } for (i = 0; i != 100; ++i) { test_recv (sb, "0123456789012345678901234567890123456789"); } test_close (sc); test_close (sb); test_text (); return 0; } nanomsg-0.8-beta/tests/zerocopy.c0000664000175000017500000001314412623652600020025 0ustar00travistravis00000000000000/* Copyright (c) 2013 GoPivotal, Inc. All rights reserved. Copyright (c) 2014 Achille Roussel. 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 "../src/nn.h" #include "../src/pubsub.h" #include "../src/reqrep.h" #include "testutil.h" #include void test_allocmsg_reqrep () { int rc; int req; void *p; struct nn_iovec iov; struct nn_msghdr hdr; /* Try to create an oversized message. */ p = nn_allocmsg (-1, 0); nn_assert (!p && nn_errno () == ENOMEM); p = nn_allocmsg (-3, 0); nn_assert (!p && nn_errno () == ENOMEM); /* Try to create a message of unknown type. */ p = nn_allocmsg (100, 333); nn_assert (!p && nn_errno () == EINVAL); /* Create a socket. */ req = test_socket (AF_SP_RAW, NN_REQ); /* Make send fail and check whether the zero-copy buffer is left alone rather than deallocated. */ p = nn_allocmsg (100, 0); nn_assert (p); rc = nn_send (req, &p, NN_MSG, NN_DONTWAIT); nn_assert (rc < 0); errno_assert (nn_errno () == EAGAIN); memset (p, 0, 100); rc = nn_freemsg (p); errno_assert (rc == 0); /* Same thing with nn_sendmsg(). */ p = nn_allocmsg (100, 0); nn_assert (p); iov.iov_base = &p; iov.iov_len = NN_MSG; memset (&hdr, 0, sizeof (hdr)); hdr.msg_iov = &iov; hdr.msg_iovlen = 1; nn_sendmsg (req, &hdr, NN_DONTWAIT); errno_assert (nn_errno () == EAGAIN); memset (p, 0, 100); rc = nn_freemsg (p); errno_assert (rc == 0); /* Clean up. */ test_close (req); } void test_reallocmsg_reqrep () { int rc; int req; int rep; void *p; void *p2; /* Create sockets. */ req = nn_socket (AF_SP, NN_REQ); rep = nn_socket (AF_SP, NN_REP); rc = nn_bind (rep, "inproc://test"); errno_assert (rc >= 0); rc = nn_connect (req, "inproc://test"); errno_assert (rc >= 0); /* Create message, make sure we handle overflow. */ p = nn_allocmsg (100, 0); nn_assert (p); p2 = nn_reallocmsg (p, (size_t)-3); errno_assert (nn_errno () == ENOMEM); nn_assert (p2 == NULL); /* Realloc to fit data size. */ memcpy (p, "Hello World!", 12); p = nn_reallocmsg (p, 12); nn_assert (p); rc = nn_send (req, &p, NN_MSG, 0); errno_assert (rc == 12); /* Receive request and send response. */ rc = nn_recv (rep, &p, NN_MSG, 0); errno_assert (rc == 12); rc = nn_send (rep, &p, NN_MSG, 0); errno_assert (rc == 12); /* Receive response and free message. */ rc = nn_recv (req, &p, NN_MSG, 0); errno_assert (rc == 12); rc = memcmp (p, "Hello World!", 12); nn_assert (rc == 0); rc = nn_freemsg (p); errno_assert (rc == 0); /* Clean up. */ nn_close (req); nn_close (rep); } void test_reallocmsg_pubsub () { int rc; int pub; int sub1; int sub2; void *p; void *p1; void *p2; /* Create sockets. */ pub = nn_socket (AF_SP, NN_PUB); sub1 = nn_socket (AF_SP, NN_SUB); sub2 = nn_socket (AF_SP, NN_SUB); rc = nn_bind (pub, "inproc://test"); errno_assert (rc >= 0); rc = nn_connect (sub1, "inproc://test"); errno_assert (rc >= 0); rc = nn_connect (sub2, "inproc://test"); errno_assert (rc >= 0); rc = nn_setsockopt (sub1, NN_SUB, NN_SUB_SUBSCRIBE, "", 0); errno_assert (rc == 0); rc = nn_setsockopt (sub2, NN_SUB, NN_SUB_SUBSCRIBE, "", 0); errno_assert (rc == 0); /* Publish message. */ p = nn_allocmsg (12, 0); nn_assert (p); memcpy (p, "Hello World!", 12); rc = nn_send (pub, &p, NN_MSG, 0); errno_assert (rc == 12); /* Receive messages, both messages are the same object with inproc. */ rc = nn_recv (sub1, &p1, NN_MSG, 0); errno_assert (rc == 12); rc = nn_recv (sub2, &p2, NN_MSG, 0); errno_assert (rc == 12); nn_assert (p1 == p2); rc = memcmp (p1, "Hello World!", 12); nn_assert (rc == 0); rc = memcmp (p2, "Hello World!", 12); nn_assert (rc == 0); /* Reallocate one message, both messages shouldn't be the same object anymore. */ p1 = nn_reallocmsg (p1, 15); errno_assert (p1); nn_assert (p1 != p2); memcpy (((char*) p1) + 12, " 42", 3); rc = memcmp (p1, "Hello World! 42", 15); nn_assert (rc == 0); /* Release messages. */ rc = nn_freemsg (p1); errno_assert (rc == 0); rc = nn_freemsg (p2); errno_assert (rc == 0); /* Clean up. */ nn_close (sub2); nn_close (sub1); nn_close (pub); } int main () { test_allocmsg_reqrep (); test_reallocmsg_reqrep (); test_reallocmsg_pubsub (); return 0; } nanomsg-0.8-beta/tests/testutil.h0000664000175000017500000001500212623652600020030 0ustar00travistravis00000000000000/* Copyright (c) 2013 Insollo Entertainment, LLC. All rights reserved. Copyright 2015 Garrett D'Amore 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. */ #ifndef TESTUTIL_H_INCLUDED #define TESTUTIL_H_INCLUDED #include "../src/utils/attr.h" #include "../src/utils/err.c" #include "../src/utils/sleep.c" static int test_socket_impl (char *file, int line, int family, int protocol); static int test_connect_impl (char *file, int line, int sock, char *address); static int test_bind_impl (char *file, int line, int sock, char *address); static void test_close_impl (char *file, int line, int sock); static void test_send_impl (char *file, int line, int sock, char *data); static void test_recv_impl (char *file, int line, int sock, char *data); static void test_drop_impl (char *file, int line, int sock, int err); static int test_setsockopt_impl (char *file, int line, int sock, int level, int option, const void *optval, size_t optlen); #define test_socket(f, p) test_socket_impl (__FILE__, __LINE__, (f), (p)) #define test_connect(s, a) test_connect_impl (__FILE__, __LINE__, (s), (a)) #define test_bind(s, a) test_bind_impl (__FILE__, __LINE__, (s), (a)) #define test_send(s, d) test_send_impl (__FILE__, __LINE__, (s), (d)) #define test_recv(s, d) test_recv_impl (__FILE__, __LINE__, (s), (d)) #define test_drop(s, e) test_drop_impl (__FILE__, __LINE__, (s), (e)) #define test_close(s) test_close_impl (__FILE__, __LINE__, (s)) #define test_setsockopt(s, l, o, v, z) test_setsockopt_impl (__FILE__, \ __LINE__, (s), (l), (o), (v), (z)) static int NN_UNUSED test_socket_impl (char *file, int line, int family, int protocol) { int sock; sock = nn_socket (family, protocol); if (sock == -1) { fprintf (stderr, "Failed create socket: %s [%d] (%s:%d)\n", nn_err_strerror (errno), (int) errno, file, line); nn_err_abort (); } return sock; } static int NN_UNUSED test_connect_impl (char *file, int line, int sock, char *address) { int rc; rc = nn_connect (sock, address); if(rc < 0) { fprintf (stderr, "Failed connect to \"%s\": %s [%d] (%s:%d)\n", address, nn_err_strerror (errno), (int) errno, file, line); nn_err_abort (); } return rc; } static int NN_UNUSED test_bind_impl (char *file, int line, int sock, char *address) { int rc; rc = nn_bind (sock, address); if(rc < 0) { fprintf (stderr, "Failed bind to \"%s\": %s [%d] (%s:%d)\n", address, nn_err_strerror (errno), (int) errno, file, line); nn_err_abort (); } return rc; } static int NN_UNUSED test_setsockopt_impl (char *file, int line, int sock, int level, int option, const void *optval, size_t optlen) { int rc; rc = nn_setsockopt (sock, level, option, optval, optlen); if(rc < 0) { fprintf (stderr, "Failed set option \"%d\": %s [%d] (%s:%d)\n", option, nn_err_strerror (errno), (int) errno, file, line); nn_err_abort (); } return rc; } static void NN_UNUSED test_close_impl (char *file, int line, int sock) { int rc; rc = nn_close (sock); if ((rc != 0) && (errno != EBADF && errno != ETERM)) { fprintf (stderr, "Failed to close socket: %s [%d] (%s:%d)\n", nn_err_strerror (errno), (int) errno, file, line); nn_err_abort (); } } static void NN_UNUSED test_send_impl (char *file, int line, int sock, char *data) { size_t data_len; int rc; data_len = strlen (data); rc = nn_send (sock, data, data_len, 0); if (rc < 0) { fprintf (stderr, "Failed to send: %s [%d] (%s:%d)\n", nn_err_strerror (errno), (int) errno, file, line); nn_err_abort (); } if (rc != (int)data_len) { fprintf (stderr, "Data to send is truncated: %d != %d (%s:%d)\n", rc, (int) data_len, file, line); nn_err_abort (); } } static void NN_UNUSED test_recv_impl (char *file, int line, int sock, char *data) { size_t data_len; int rc; char *buf; data_len = strlen (data); /* We allocate plus one byte so that we are sure that message received has correct length and not truncated */ buf = malloc (data_len+1); alloc_assert (buf); rc = nn_recv (sock, buf, data_len+1, 0); if (rc < 0) { fprintf (stderr, "Failed to recv: %s [%d] (%s:%d)\n", nn_err_strerror (errno), (int) errno, file, line); nn_err_abort (); } if (rc != (int)data_len) { fprintf (stderr, "Received data has wrong length: %d != %d (%s:%d)\n", rc, (int) data_len, file, line); nn_err_abort (); } if (memcmp (data, buf, data_len) != 0) { /* We don't print the data as it may have binary garbage */ fprintf (stderr, "Received data is wrong (%s:%d)\n", file, line); nn_err_abort (); } free (buf); } static void NN_UNUSED test_drop_impl (char *file, int line, int sock, int err) { int rc; char buf[1024]; rc = nn_recv (sock, buf, sizeof (buf), 0); if (rc < 0 && err != errno) { fprintf (stderr, "Got wrong err to recv: %s [%d != %d] (%s:%d)\n", nn_err_strerror (errno), (int) errno, err, file, line); nn_err_abort (); } else if (rc >= 0) { fprintf (stderr, "Did not drop message: [%d bytes] (%s:%d)\n", rc, file, line); nn_err_abort (); } } #endif nanomsg-0.8-beta/tools/0000775000175000017500000000000012623652617016012 5ustar00travistravis00000000000000nanomsg-0.8-beta/tools/nanocat.c0000664000175000017500000005420712623652600017601 0ustar00travistravis00000000000000/* Copyright (c) 2013 Insollo Entertainment, LLC. 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 "../src/nn.h" #include "../src/pubsub.h" #include "../src/pipeline.h" #include "../src/bus.h" #include "../src/pair.h" #include "../src/survey.h" #include "../src/reqrep.h" #include "options.h" #include "../src/utils/sleep.c" #include "../src/utils/clock.c" #include #include #include #include #include #include #if !defined NN_HAVE_WINDOWS #include #endif enum echo_format { NN_NO_ECHO, NN_ECHO_RAW, NN_ECHO_ASCII, NN_ECHO_QUOTED, NN_ECHO_MSGPACK, NN_ECHO_HEX }; typedef struct nn_options { /* Global options */ int verbose; /* Socket options */ int socket_type; struct nn_string_list bind_addresses; struct nn_string_list connect_addresses; float send_timeout; float recv_timeout; struct nn_string_list subscriptions; char *socket_name; /* Output options */ float send_delay; float send_interval; struct nn_blob data_to_send; /* Input options */ enum echo_format echo_format; } nn_options_t; /* Constants to get address of in option declaration */ static const int nn_push = NN_PUSH; static const int nn_pull = NN_PULL; static const int nn_pub = NN_PUB; static const int nn_sub = NN_SUB; static const int nn_req = NN_REQ; static const int nn_rep = NN_REP; static const int nn_bus = NN_BUS; static const int nn_pair = NN_PAIR; static const int nn_surveyor = NN_SURVEYOR; static const int nn_respondent = NN_RESPONDENT; struct nn_enum_item socket_types[] = { {"PUSH", NN_PUSH}, {"PULL", NN_PULL}, {"PUB", NN_PUB}, {"SUB", NN_SUB}, {"REQ", NN_REQ}, {"REP", NN_REP}, {"BUS", NN_BUS}, {"PAIR", NN_PAIR}, {"SURVEYOR", NN_SURVEYOR}, {"RESPONDENT", NN_RESPONDENT}, {NULL, 0}, }; /* Constants to get address of in option declaration */ static const int nn_echo_raw = NN_ECHO_RAW; static const int nn_echo_ascii = NN_ECHO_ASCII; static const int nn_echo_quoted = NN_ECHO_QUOTED; static const int nn_echo_msgpack = NN_ECHO_MSGPACK; static const int nn_echo_hex = NN_ECHO_HEX; struct nn_enum_item echo_formats[] = { {"no", NN_NO_ECHO}, {"raw", NN_ECHO_RAW}, {"ascii", NN_ECHO_ASCII}, {"quoted", NN_ECHO_QUOTED}, {"msgpack", NN_ECHO_MSGPACK}, {"hex", NN_ECHO_HEX}, {NULL, 0}, }; /* Constants for conflict masks */ #define NN_MASK_SOCK 1 #define NN_MASK_WRITEABLE 2 #define NN_MASK_READABLE 4 #define NN_MASK_SOCK_SUB 8 #define NN_MASK_DATA 16 #define NN_MASK_ENDPOINT 32 #define NN_NO_PROVIDES 0 #define NN_NO_CONFLICTS 0 #define NN_NO_REQUIRES 0 #define NN_MASK_SOCK_WRITEABLE (NN_MASK_SOCK | NN_MASK_WRITEABLE) #define NN_MASK_SOCK_READABLE (NN_MASK_SOCK | NN_MASK_READABLE) #define NN_MASK_SOCK_READWRITE (NN_MASK_SOCK_WRITEABLE|NN_MASK_SOCK_READABLE) struct nn_option nn_options[] = { /* Generic options */ {"verbose", 'v', NULL, NN_OPT_INCREMENT, offsetof (nn_options_t, verbose), NULL, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_NO_REQUIRES, "Generic", NULL, "Increase verbosity of the nanocat"}, {"silent", 'q', NULL, NN_OPT_DECREMENT, offsetof (nn_options_t, verbose), NULL, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_NO_REQUIRES, "Generic", NULL, "Decrease verbosity of the nanocat"}, {"help", 'h', NULL, NN_OPT_HELP, 0, NULL, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_NO_REQUIRES, "Generic", NULL, "This help text"}, /* Socket types */ {"push", 0, "nn_push", NN_OPT_SET_ENUM, offsetof (nn_options_t, socket_type), &nn_push, NN_MASK_SOCK_WRITEABLE, NN_MASK_SOCK, NN_MASK_DATA, "Socket Types", NULL, "Use NN_PUSH socket type"}, {"pull", 0, "nn_pull", NN_OPT_SET_ENUM, offsetof (nn_options_t, socket_type), &nn_pull, NN_MASK_SOCK_READABLE, NN_MASK_SOCK, NN_NO_REQUIRES, "Socket Types", NULL, "Use NN_PULL socket type"}, {"pub", 0, "nn_pub", NN_OPT_SET_ENUM, offsetof (nn_options_t, socket_type), &nn_pub, NN_MASK_SOCK_WRITEABLE, NN_MASK_SOCK, NN_MASK_DATA, "Socket Types", NULL, "Use NN_PUB socket type"}, {"sub", 0, "nn_sub", NN_OPT_SET_ENUM, offsetof (nn_options_t, socket_type), &nn_sub, NN_MASK_SOCK_READABLE|NN_MASK_SOCK_SUB, NN_MASK_SOCK, NN_NO_REQUIRES, "Socket Types", NULL, "Use NN_SUB socket type"}, {"req", 0, "nn_req", NN_OPT_SET_ENUM, offsetof (nn_options_t, socket_type), &nn_req, NN_MASK_SOCK_READWRITE, NN_MASK_SOCK, NN_MASK_DATA, "Socket Types", NULL, "Use NN_REQ socket type"}, {"rep", 0, "nn_rep", NN_OPT_SET_ENUM, offsetof (nn_options_t, socket_type), &nn_rep, NN_MASK_SOCK_READWRITE, NN_MASK_SOCK, NN_NO_REQUIRES, "Socket Types", NULL, "Use NN_REP socket type"}, {"surveyor", 0, "nn_surveyor", NN_OPT_SET_ENUM, offsetof (nn_options_t, socket_type), &nn_surveyor, NN_MASK_SOCK_READWRITE, NN_MASK_SOCK, NN_MASK_DATA, "Socket Types", NULL, "Use NN_SURVEYOR socket type"}, {"respondent", 0, "nn_respondent", NN_OPT_SET_ENUM, offsetof (nn_options_t, socket_type), &nn_respondent, NN_MASK_SOCK_READWRITE, NN_MASK_SOCK, NN_NO_REQUIRES, "Socket Types", NULL, "Use NN_RESPONDENT socket type"}, {"bus", 0, "nn_bus", NN_OPT_SET_ENUM, offsetof (nn_options_t, socket_type), &nn_bus, NN_MASK_SOCK_READWRITE, NN_MASK_SOCK, NN_NO_REQUIRES, "Socket Types", NULL, "Use NN_BUS socket type"}, {"pair", 0, "nn_pair", NN_OPT_SET_ENUM, offsetof (nn_options_t, socket_type), &nn_pair, NN_MASK_SOCK_READWRITE, NN_MASK_SOCK, NN_NO_REQUIRES, "Socket Types", NULL, "Use NN_PAIR socket type"}, /* Socket Options */ {"bind", 0, NULL, NN_OPT_LIST_APPEND, offsetof (nn_options_t, bind_addresses), NULL, NN_MASK_ENDPOINT, NN_NO_CONFLICTS, NN_NO_REQUIRES, "Socket Options", "ADDR", "Bind socket to the address ADDR"}, {"connect", 0, NULL, NN_OPT_LIST_APPEND, offsetof (nn_options_t, connect_addresses), NULL, NN_MASK_ENDPOINT, NN_NO_CONFLICTS, NN_NO_REQUIRES, "Socket Options", "ADDR", "Connect socket to the address ADDR"}, {"bind-ipc", 'X' , NULL, NN_OPT_LIST_APPEND_FMT, offsetof (nn_options_t, bind_addresses), "ipc://%s", NN_MASK_ENDPOINT, NN_NO_CONFLICTS, NN_NO_REQUIRES, "Socket Options", "PATH", "Bind socket to the ipc address " "\"ipc://PATH\"."}, {"connect-ipc", 'x' , NULL, NN_OPT_LIST_APPEND_FMT, offsetof (nn_options_t, connect_addresses), "ipc://%s", NN_MASK_ENDPOINT, NN_NO_CONFLICTS, NN_NO_REQUIRES, "Socket Options", "PATH", "Connect socket to the ipc address " "\"ipc://PATH\"."}, {"bind-local", 'L' , NULL, NN_OPT_LIST_APPEND_FMT, offsetof (nn_options_t, bind_addresses), "tcp://127.0.0.1:%s", NN_MASK_ENDPOINT, NN_NO_CONFLICTS, NN_NO_REQUIRES, "Socket Options", "PORT", "Bind socket to the tcp address " "\"tcp://127.0.0.1:PORT\"."}, {"connect-local", 'l' , NULL, NN_OPT_LIST_APPEND_FMT, offsetof (nn_options_t, connect_addresses), "tcp://127.0.0.1:%s", NN_MASK_ENDPOINT, NN_NO_CONFLICTS, NN_NO_REQUIRES, "Socket Options", "PORT", "Connect socket to the tcp address " "\"tcp://127.0.0.1:PORT\"."}, {"recv-timeout", 0, NULL, NN_OPT_FLOAT, offsetof (nn_options_t, recv_timeout), NULL, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_MASK_READABLE, "Socket Options", "SEC", "Set timeout for receiving a message"}, {"send-timeout", 0, NULL, NN_OPT_FLOAT, offsetof (nn_options_t, send_timeout), NULL, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_MASK_WRITEABLE, "Socket Options", "SEC", "Set timeout for sending a message"}, {"socket-name", 0, NULL, NN_OPT_STRING, offsetof (nn_options_t, socket_name), NULL, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_NO_REQUIRES, "Socket Options", "NAME", "Name of the socket for statistics"}, /* Pattern-specific options */ {"subscribe", 0, NULL, NN_OPT_LIST_APPEND, offsetof (nn_options_t, subscriptions), NULL, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_MASK_SOCK_SUB, "SUB Socket Options", "PREFIX", "Subscribe to the prefix PREFIX. " "Note: socket will be subscribed to everything (empty prefix) if " "no prefixes are specified on the command-line."}, /* Input Options */ {"format", 0, NULL, NN_OPT_ENUM, offsetof (nn_options_t, echo_format), &echo_formats, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_MASK_READABLE, "Input Options", "FORMAT", "Use echo format FORMAT " "(same as the options below)"}, {"raw", 0, NULL, NN_OPT_SET_ENUM, offsetof (nn_options_t, echo_format), &nn_echo_raw, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_MASK_READABLE, "Input Options", NULL, "Dump message as is " "(Note: no delimiters are printed)"}, {"ascii", 'A', NULL, NN_OPT_SET_ENUM, offsetof (nn_options_t, echo_format), &nn_echo_ascii, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_MASK_READABLE, "Input Options", NULL, "Print ASCII part of message delimited by newline. " "All non-ascii characters replaced by dot."}, {"quoted", 'Q', NULL, NN_OPT_SET_ENUM, offsetof (nn_options_t, echo_format), &nn_echo_quoted, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_MASK_READABLE, "Input Options", NULL, "Print each message on separate line in double " "quotes with C-like character escaping"}, {"msgpack", 0, NULL, NN_OPT_SET_ENUM, offsetof (nn_options_t, echo_format), &nn_echo_msgpack, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_MASK_READABLE, "Input Options", NULL, "Print each message as msgpacked string (raw type)." " This is useful for programmatic parsing."}, {"hex", 0, NULL, NN_OPT_SET_ENUM, offsetof (nn_options_t, echo_format), &nn_echo_hex, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_MASK_READABLE, "Input Options", NULL, "Print each message on separate line in double " "quotes with hex values"}, /* Output Options */ {"interval", 'i', NULL, NN_OPT_FLOAT, offsetof (nn_options_t, send_interval), NULL, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_MASK_WRITEABLE, "Output Options", "SEC", "Send message (or request) every SEC seconds"}, {"delay", 'd', NULL, NN_OPT_FLOAT, offsetof (nn_options_t, send_delay), NULL, NN_NO_PROVIDES, NN_NO_CONFLICTS, NN_NO_REQUIRES, "Output Options", "SEC", "Wait for SEC seconds before sending message" " (useful for one-shot PUB sockets)"}, {"data", 'D', NULL, NN_OPT_BLOB, offsetof (nn_options_t, data_to_send), &echo_formats, NN_MASK_DATA, NN_MASK_DATA, NN_MASK_WRITEABLE, "Output Options", "DATA", "Send DATA to the socket and quit for " "PUB, PUSH, PAIR, BUS socket. Use DATA to reply for REP or " " RESPONDENT socket. Send DATA as request for REQ or SURVEYOR socket."}, {"file", 'F', NULL, NN_OPT_READ_FILE, offsetof (nn_options_t, data_to_send), &echo_formats, NN_MASK_DATA, NN_MASK_DATA, NN_MASK_WRITEABLE, "Output Options", "PATH", "Same as --data but get data from file PATH"}, /* Sentinel */ {NULL, 0, NULL, 0, 0, NULL, 0, 0, 0, NULL, NULL, NULL}, }; struct nn_commandline nn_cli = { "A command-line interface to nanomsg", "", nn_options, NN_MASK_SOCK | NN_MASK_ENDPOINT, }; void nn_assert_errno (int flag, char *description) { int err; if (!flag) { err = errno; fprintf (stderr, "%s: %s\n", description, nn_strerror (err)); exit (3); } } void nn_sub_init (nn_options_t *options, int sock) { int i; int rc; if (options->subscriptions.num) { for (i = 0; i < options->subscriptions.num; ++i) { rc = nn_setsockopt (sock, NN_SUB, NN_SUB_SUBSCRIBE, options->subscriptions.items[i], strlen (options->subscriptions.items[i])); nn_assert_errno (rc == 0, "Can't subscribe"); } } else { rc = nn_setsockopt (sock, NN_SUB, NN_SUB_SUBSCRIBE, "", 0); nn_assert_errno (rc == 0, "Can't subscribe"); } } void nn_set_recv_timeout (int sock, int millis) { int rc; rc = nn_setsockopt (sock, NN_SOL_SOCKET, NN_RCVTIMEO, &millis, sizeof (millis)); nn_assert_errno (rc == 0, "Can't set recv timeout"); } int nn_create_socket (nn_options_t *options) { int sock; int rc; int millis; sock = nn_socket (AF_SP, options->socket_type); nn_assert_errno (sock >= 0, "Can't create socket"); /* Generic initialization */ if (options->send_timeout >= 0) { millis = (int)(options->send_timeout * 1000); rc = nn_setsockopt (sock, NN_SOL_SOCKET, NN_SNDTIMEO, &millis, sizeof (millis)); nn_assert_errno (rc == 0, "Can't set send timeout"); } if (options->recv_timeout >= 0) { nn_set_recv_timeout (sock, (int) options->recv_timeout); } if (options->socket_name) { rc = nn_setsockopt (sock, NN_SOL_SOCKET, NN_SOCKET_NAME, options->socket_name, strlen(options->socket_name)); nn_assert_errno (rc == 0, "Can't set socket name"); } /* Specific initialization */ switch (options->socket_type) { case NN_SUB: nn_sub_init (options, sock); break; } return sock; } void nn_print_message (nn_options_t *options, char *buf, int buflen) { switch (options->echo_format) { case NN_NO_ECHO: return; case NN_ECHO_RAW: fwrite (buf, 1, buflen, stdout); break; case NN_ECHO_ASCII: for (; buflen > 0; --buflen, ++buf) { if (isprint (*buf)) { fputc (*buf, stdout); } else { fputc ('.', stdout); } } fputc ('\n', stdout); break; case NN_ECHO_QUOTED: fputc ('"', stdout); for (; buflen > 0; --buflen, ++buf) { switch (*buf) { case '\n': fprintf (stdout, "\\n"); break; case '\r': fprintf (stdout, "\\r"); break; case '\\': case '\"': fprintf (stdout, "\\%c", *buf); break; default: if (isprint (*buf)) { fputc (*buf, stdout); } else { fprintf (stdout, "\\x%02x", (unsigned char)*buf); } } } fprintf (stdout, "\"\n"); break; case NN_ECHO_MSGPACK: if (buflen < 256) { fputc ('\xc4', stdout); fputc (buflen, stdout); fwrite (buf, 1, buflen, stdout); } else if (buflen < 65536) { fputc ('\xc5', stdout); fputc (buflen >> 8, stdout); fputc (buflen & 0xff, stdout); fwrite (buf, 1, buflen, stdout); } else { fputc ('\xc6', stdout); fputc (buflen >> 24, stdout); fputc ((buflen >> 16) & 0xff, stdout); fputc ((buflen >> 8) & 0xff, stdout); fputc (buflen & 0xff, stdout); fwrite (buf, 1, buflen, stdout); } break; case NN_ECHO_HEX: fputc ('"', stdout); for (; buflen > 0; --buflen, ++buf) { fprintf (stdout, "\\x%02x", (unsigned char)*buf); } fprintf (stdout, "\"\n"); break; } fflush (stdout); } void nn_connect_socket (nn_options_t *options, int sock) { int i; int rc; for (i = 0; i < options->bind_addresses.num; ++i) { rc = nn_bind (sock, options->bind_addresses.items[i]); nn_assert_errno (rc >= 0, "Can't bind"); } for (i = 0; i < options->connect_addresses.num; ++i) { rc = nn_connect (sock, options->connect_addresses.items[i]); nn_assert_errno (rc >= 0, "Can't connect"); } } void nn_send_loop (nn_options_t *options, int sock) { int rc; uint64_t start_time; int64_t time_to_sleep, interval; struct nn_clock clock; interval = (int)(options->send_interval*1000); nn_clock_init (&clock); for (;;) { start_time = nn_clock_now (&clock); rc = nn_send (sock, options->data_to_send.data, options->data_to_send.length, 0); if (rc < 0 && errno == EAGAIN) { fprintf (stderr, "Message not sent (EAGAIN)\n"); } else { nn_assert_errno (rc >= 0, "Can't send"); } if (interval >= 0) { time_to_sleep = (start_time + interval) - nn_clock_now (&clock); if (time_to_sleep > 0) { nn_sleep ((int) time_to_sleep); } } else { break; } } nn_clock_term(&clock); } void nn_recv_loop (nn_options_t *options, int sock) { int rc; void *buf; for (;;) { rc = nn_recv (sock, &buf, NN_MSG, 0); if (rc < 0 && errno == EAGAIN) { continue; } else if (rc < 0 && (errno == ETIMEDOUT || errno == EFSM)) { return; /* No more messages possible */ } else { nn_assert_errno (rc >= 0, "Can't recv"); } nn_print_message (options, buf, rc); nn_freemsg (buf); } } void nn_rw_loop (nn_options_t *options, int sock) { int rc; void *buf; uint64_t start_time; int64_t time_to_sleep, interval, recv_timeout; struct nn_clock clock; interval = (int)(options->send_interval*1000); recv_timeout = (int)(options->recv_timeout*1000); nn_clock_init (&clock); for (;;) { start_time = nn_clock_now (&clock); rc = nn_send (sock, options->data_to_send.data, options->data_to_send.length, 0); if (rc < 0 && errno == EAGAIN) { fprintf (stderr, "Message not sent (EAGAIN)\n"); } else { nn_assert_errno (rc >= 0, "Can't send"); } if (options->send_interval < 0) { /* Never send any more */ nn_recv_loop (options, sock); return; } for (;;) { time_to_sleep = (start_time + interval) - nn_clock_now (&clock); if (time_to_sleep <= 0) { break; } if (recv_timeout >= 0 && time_to_sleep > recv_timeout) { time_to_sleep = recv_timeout; } nn_set_recv_timeout (sock, (int) time_to_sleep); rc = nn_recv (sock, &buf, NN_MSG, 0); if (rc < 0) { if (errno == EAGAIN) { continue; } else if (errno == ETIMEDOUT || errno == EFSM) { time_to_sleep = (start_time + interval) - nn_clock_now (&clock); if (time_to_sleep > 0) nn_sleep ((int) time_to_sleep); continue; } } nn_assert_errno (rc >= 0, "Can't recv"); nn_print_message (options, buf, rc); nn_freemsg (buf); } } nn_clock_term(&clock); } void nn_resp_loop (nn_options_t *options, int sock) { int rc; void *buf; for (;;) { rc = nn_recv (sock, &buf, NN_MSG, 0); if (rc < 0 && errno == EAGAIN) { continue; } else { nn_assert_errno (rc >= 0, "Can't recv"); } nn_print_message (options, buf, rc); nn_freemsg (buf); rc = nn_send (sock, options->data_to_send.data, options->data_to_send.length, 0); if (rc < 0 && errno == EAGAIN) { fprintf (stderr, "Message not sent (EAGAIN)\n"); } else { nn_assert_errno (rc >= 0, "Can't send"); } } } int main (int argc, char **argv) { int sock; nn_options_t options = { /* verbose */ 0, /* socket_type */ 0, /* bind_addresses */ {NULL, NULL, 0, 0}, /* connect_addresses */ {NULL, NULL, 0, 0}, /* send_timeout */ -1.f, /* recv_timeout */ -1.f, /* subscriptions */ {NULL, NULL, 0, 0}, /* socket_name */ NULL, /* send_delay */ 0.f, /* send_interval */ -1.f, /* data_to_send */ {NULL, 0, 0}, /* echo_format */ NN_NO_ECHO }; nn_parse_options (&nn_cli, &options, argc, argv); sock = nn_create_socket (&options); nn_connect_socket (&options, sock); nn_sleep((int)(options.send_delay*1000)); switch (options.socket_type) { case NN_PUB: case NN_PUSH: nn_send_loop (&options, sock); break; case NN_SUB: case NN_PULL: nn_recv_loop (&options, sock); break; case NN_BUS: case NN_PAIR: if (options.data_to_send.data) { nn_rw_loop (&options, sock); } else { nn_recv_loop (&options, sock); } break; case NN_SURVEYOR: case NN_REQ: nn_rw_loop (&options, sock); break; case NN_REP: case NN_RESPONDENT: if (options.data_to_send.data) { nn_resp_loop (&options, sock); } else { nn_recv_loop (&options, sock); } break; } nn_close (sock); nn_free_options(&nn_cli, &options); return 0; } nanomsg-0.8-beta/tools/options.c0000664000175000017500000005676012623652600017657 0ustar00travistravis00000000000000/* Copyright (c) 2013 Insollo Entertainment, LLC. 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 "options.h" #include "../src/utils/err.c" #include #include #include #include #include #include struct nn_parse_context { /* Initial state */ struct nn_commandline *def; struct nn_option *options; void *target; int argc; char **argv; unsigned long requires; /* Current values */ unsigned long mask; int args_left; char **arg; char *data; char **last_option_usage; }; static int nn_has_arg (struct nn_option *opt) { switch (opt->type) { case NN_OPT_INCREMENT: case NN_OPT_DECREMENT: case NN_OPT_SET_ENUM: case NN_OPT_HELP: return 0; case NN_OPT_ENUM: case NN_OPT_STRING: case NN_OPT_BLOB: case NN_OPT_FLOAT: case NN_OPT_INT: case NN_OPT_LIST_APPEND: case NN_OPT_LIST_APPEND_FMT: case NN_OPT_READ_FILE: return 1; } nn_assert (0); } static void nn_print_usage (struct nn_parse_context *ctx, FILE *stream) { int i; int first; struct nn_option *opt; fprintf (stream, " %s ", ctx->argv[0]); /* Print required options (long names) */ first = 1; for (i = 0;; ++i) { opt = &ctx->options[i]; if (!opt->longname) break; if (opt->mask_set & ctx->requires) { if (first) { first = 0; fprintf (stream, "{--%s", opt->longname); } else { fprintf (stream, "|--%s", opt->longname); } } } if (!first) { fprintf (stream, "} "); } /* Print flag short options */ first = 1; for (i = 0;; ++i) { opt = &ctx->options[i]; if (!opt->longname) break; if (opt->mask_set & ctx->requires) continue; /* already printed */ if (opt->shortname && !nn_has_arg (opt)) { if (first) { first = 0; fprintf (stream, "[-%c", opt->shortname); } else { fprintf (stream, "%c", opt->shortname); } } } if (!first) { fprintf (stream, "] "); } /* Print short options with arguments */ for (i = 0;; ++i) { opt = &ctx->options[i]; if (!opt->longname) break; if (opt->mask_set & ctx->requires) continue; /* already printed */ if (opt->shortname && nn_has_arg (opt) && opt->metavar) { fprintf (stream, "[-%c %s] ", opt->shortname, opt->metavar); } } fprintf (stream, "[options] \n"); /* There may be long options too */ } static char *nn_print_line (FILE *out, char *str, size_t width) { int i; if (strlen (str) < width) { fprintf (out, "%s", str); return ""; } for (i = width; i > 1; --i) { if (isspace (str[i])) { fprintf (out, "%.*s", i, str); return str + i + 1; } } /* no break points, just print as is */ fprintf (out, "%s", str); return ""; } static void nn_print_help (struct nn_parse_context *ctx, FILE *stream) { int i; int optlen; struct nn_option *opt; char *last_group; char *cursor; fprintf (stream, "Usage:\n"); nn_print_usage (ctx, stream); fprintf (stream, "\n%s\n", ctx->def->short_description); last_group = NULL; for (i = 0;; ++i) { opt = &ctx->options[i]; if (!opt->longname) break; if (!last_group || last_group != opt->group || strcmp (last_group, opt->group)) { fprintf (stream, "\n"); fprintf (stream, "%s:\n", opt->group); last_group = opt->group; } fprintf (stream, " --%s", opt->longname); optlen = 3 + strlen (opt->longname); if (opt->shortname) { fprintf (stream, ",-%c", opt->shortname); optlen += 3; } if (nn_has_arg (opt)) { if (opt->metavar) { fprintf (stream, " %s", opt->metavar); optlen += strlen (opt->metavar) + 1; } else { fprintf (stream, " ARG"); optlen += 4; } } if (optlen < 23) { fputs (&" "[optlen], stream); cursor = nn_print_line (stream, opt->description, 80-24); } else { cursor = opt->description; } while (*cursor) { fprintf (stream, "\n "); cursor = nn_print_line (stream, cursor, 80-24); } fprintf (stream, "\n"); } } static void nn_print_option (struct nn_parse_context *ctx, int opt_index, FILE *stream) { char *ousage; char *oend; size_t olen; struct nn_option *opt; opt = &ctx->options[opt_index]; ousage = ctx->last_option_usage[opt_index]; if (*ousage == '-') { /* Long option */ oend = strchr (ousage, '='); if (!oend) { olen = strlen (ousage); } else { olen = (oend - ousage); } if (olen != strlen (opt->longname)+2) { fprintf (stream, " %.*s[%s] ", (int)olen, ousage, opt->longname + (olen-2)); } else { fprintf (stream, " %s ", ousage); } } else if (ousage == ctx->argv[0]) { /* Binary name */ fprintf (stream, " %s (executable) ", ousage); } else { /* Short option */ fprintf (stream, " -%c (--%s) ", *ousage, opt->longname); } } static void nn_option_error (char *message, struct nn_parse_context *ctx, int opt_index) { fprintf (stderr, "%s: Option", ctx->argv[0]); nn_print_option (ctx, opt_index, stderr); fprintf (stderr, "%s\n", message); exit (1); } static void nn_memory_error (struct nn_parse_context *ctx) { fprintf (stderr, "%s: Memory error while parsing command-line", ctx->argv[0]); abort (); } static void nn_invalid_enum_value (struct nn_parse_context *ctx, int opt_index, char *argument) { struct nn_option *opt; struct nn_enum_item *items; opt = &ctx->options[opt_index]; items = (struct nn_enum_item *)opt->pointer; fprintf (stderr, "%s: Invalid value ``%s'' for", ctx->argv[0], argument); nn_print_option (ctx, opt_index, stderr); fprintf (stderr, ". Options are:\n"); for (;items->name; ++items) { fprintf (stderr, " %s\n", items->name); } exit (1); } static void nn_option_conflict (struct nn_parse_context *ctx, int opt_index) { unsigned long mask; int i; int num_conflicts; struct nn_option *opt; fprintf (stderr, "%s: Option", ctx->argv[0]); nn_print_option (ctx, opt_index, stderr); fprintf (stderr, "conflicts with the following options:\n"); mask = ctx->options[opt_index].conflicts_mask; num_conflicts = 0; for (i = 0;; ++i) { opt = &ctx->options[i]; if (!opt->longname) break; if (i == opt_index) continue; if (ctx->last_option_usage[i] && opt->mask_set & mask) { num_conflicts += 1; fprintf (stderr, " "); nn_print_option (ctx, i, stderr); fprintf (stderr, "\n"); } } if (!num_conflicts) { fprintf (stderr, " "); nn_print_option (ctx, opt_index, stderr); fprintf (stderr, "\n"); } exit (1); } static void nn_print_requires (struct nn_parse_context *ctx, unsigned long mask) { int i; struct nn_option *opt; for (i = 0;; ++i) { opt = &ctx->options[i]; if (!opt->longname) break; if (opt->mask_set & mask) { fprintf (stderr, " --%s\n", opt->longname); if (opt->shortname) { fprintf (stderr, " -%c\n", opt->shortname); } } } exit (1); } static void nn_option_requires (struct nn_parse_context *ctx, int opt_index) { fprintf (stderr, "%s: Option", ctx->argv[0]); nn_print_option (ctx, opt_index, stderr); fprintf (stderr, "requires at least one of the following options:\n"); nn_print_requires (ctx, ctx->options[opt_index].requires_mask); exit (1); } static void nn_append_string (struct nn_parse_context *ctx, struct nn_option *opt, char *str) { struct nn_string_list *lst; lst = (struct nn_string_list *)( ((char *)ctx->target) + opt->offset); if (lst->items) { lst->num += 1; lst->items = realloc (lst->items, sizeof (char *) * lst->num); } else { lst->items = malloc (sizeof (char *)); lst->num = 1; } if (!lst->items) { nn_memory_error (ctx); } lst->items[lst->num-1] = str; } static void nn_append_string_to_free (struct nn_parse_context *ctx, struct nn_option *opt, char *str) { struct nn_string_list *lst; lst = (struct nn_string_list *)( ((char *)ctx->target) + opt->offset); if (lst->to_free) { lst->to_free_num += 1; lst->to_free = realloc (lst->items, sizeof (char *) * lst->to_free_num); } else { lst->to_free = malloc (sizeof (char *)); lst->to_free_num = 1; } if (!lst->items) { nn_memory_error (ctx); } lst->to_free[lst->to_free_num-1] = str; } static void nn_process_option (struct nn_parse_context *ctx, int opt_index, char *argument) { struct nn_option *opt; struct nn_enum_item *items; char *endptr; struct nn_blob *blob; FILE *file; char *data; size_t data_len; size_t data_buf; int bytes_read; opt = &ctx->options[opt_index]; if (ctx->mask & opt->conflicts_mask) { nn_option_conflict (ctx, opt_index); } ctx->mask |= opt->mask_set; switch (opt->type) { case NN_OPT_HELP: nn_print_help (ctx, stdout); exit (0); return; case NN_OPT_INT: *(long *)(((char *)ctx->target) + opt->offset) = strtol (argument, &endptr, 0); if (endptr == argument || *endptr != 0) { nn_option_error ("requires integer argument", ctx, opt_index); } return; case NN_OPT_INCREMENT: *(int *)(((char *)ctx->target) + opt->offset) += 1; return; case NN_OPT_DECREMENT: *(int *)(((char *)ctx->target) + opt->offset) -= 1; return; case NN_OPT_ENUM: items = (struct nn_enum_item *)opt->pointer; for (;items->name; ++items) { if (!strcmp (items->name, argument)) { *(int *)(((char *)ctx->target) + opt->offset) = \ items->value; return; } } nn_invalid_enum_value (ctx, opt_index, argument); return; case NN_OPT_SET_ENUM: *(int *)(((char *)ctx->target) + opt->offset) = \ *(int *)(opt->pointer); return; case NN_OPT_STRING: *(char **)(((char *)ctx->target) + opt->offset) = argument; return; case NN_OPT_BLOB: blob = (struct nn_blob *)(((char *)ctx->target) + opt->offset); blob->data = argument; blob->length = strlen (argument); blob->need_free = 0; return; case NN_OPT_FLOAT: #if defined NN_HAVE_WINDOWS *(float *)(((char *)ctx->target) + opt->offset) = (float) atof (argument); #else *(float *)(((char *)ctx->target) + opt->offset) = strtof (argument, &endptr); if (endptr == argument || *endptr != 0) { nn_option_error ("requires float point argument", ctx, opt_index); } #endif return; case NN_OPT_LIST_APPEND: nn_append_string (ctx, opt, argument); return; case NN_OPT_LIST_APPEND_FMT: data_buf = strlen (argument) + strlen (opt->pointer); data = malloc (data_buf); #if defined NN_HAVE_WINDOWS data_len = _snprintf_s (data, data_buf, _TRUNCATE, opt->pointer, argument); #else data_len = snprintf (data, data_buf, opt->pointer, argument); #endif assert (data_len < data_buf); nn_append_string (ctx, opt, data); nn_append_string_to_free (ctx, opt, data); return; case NN_OPT_READ_FILE: if (!strcmp (argument, "-")) { file = stdin; } else { file = fopen (argument, "r"); if (!file) { fprintf (stderr, "Error opening file ``%s'': %s\n", argument, strerror (errno)); exit (2); } } data = malloc (4096); if (!data) nn_memory_error (ctx); data_len = 0; data_buf = 4096; for (;;) { bytes_read = fread (data + data_len, 1, data_buf - data_len, file); data_len += bytes_read; if (feof (file)) break; if (data_buf - data_len < 1024) { if (data_buf < (1 << 20)) { data_buf *= 2; /* grow twice until not too big */ } else { data_buf += 1 << 20; /* grow 1 Mb each time */ } data = realloc (data, data_buf); if (!data) nn_memory_error (ctx); } } if (data_len != data_buf) { data = realloc (data, data_len); assert (data); } if (ferror (file)) { #if defined _MSC_VER #pragma warning (push) #pragma warning (disable:4996) #endif fprintf (stderr, "Error reading file ``%s'': %s\n", argument, strerror (errno)); #if defined _MSC_VER #pragma warning (pop) #endif exit (2); } if (file != stdin) { fclose (file); } blob = (struct nn_blob *)(((char *)ctx->target) + opt->offset); blob->data = data; blob->length = data_len; blob->need_free = 1; return; } abort (); } static void nn_parse_arg0 (struct nn_parse_context *ctx) { int i; struct nn_option *opt; char *arg0; arg0 = strrchr (ctx->argv[0], '/'); if (arg0 == NULL) { arg0 = ctx->argv[0]; } else { arg0 += 1; /* Skip slash itself */ } for (i = 0;; ++i) { opt = &ctx->options[i]; if (!opt->longname) return; if (opt->arg0name && !strcmp (arg0, opt->arg0name)) { assert (!nn_has_arg (opt)); ctx->last_option_usage[i] = ctx->argv[0]; nn_process_option (ctx, i, NULL); } } } static void nn_error_ambiguous_option (struct nn_parse_context *ctx) { struct nn_option *opt; char *a, *b; char *arg; arg = ctx->data+2; fprintf (stderr, "%s: Ambiguous option ``%s'':\n", ctx->argv[0], ctx->data); for (opt = ctx->options; opt->longname; ++opt) { for (a = opt->longname, b = arg; ; ++a, ++b) { if (*b == 0 || *b == '=') { /* End of option on command-line */ fprintf (stderr, " %s\n", opt->longname); break; } else if (*b != *a) { break; } } } exit (1); } static void nn_error_unknown_long_option (struct nn_parse_context *ctx) { fprintf (stderr, "%s: Unknown option ``%s''\n", ctx->argv[0], ctx->data); exit (1); } static void nn_error_unexpected_argument (struct nn_parse_context *ctx) { fprintf (stderr, "%s: Unexpected argument ``%s''\n", ctx->argv[0], ctx->data); exit (1); } static void nn_error_unknown_short_option (struct nn_parse_context *ctx) { fprintf (stderr, "%s: Unknown option ``-%c''\n", ctx->argv[0], *ctx->data); exit (1); } static int nn_get_arg (struct nn_parse_context *ctx) { if (!ctx->args_left) return 0; ctx->args_left -= 1; ctx->arg += 1; ctx->data = *ctx->arg; return 1; } static void nn_parse_long_option (struct nn_parse_context *ctx) { struct nn_option *opt; char *a, *b; int longest_prefix; int cur_prefix; int best_match; char *arg; int i; arg = ctx->data+2; longest_prefix = 0; best_match = -1; for (i = 0;; ++i) { opt = &ctx->options[i]; if (!opt->longname) break; for (a = opt->longname, b = arg;; ++a, ++b) { if (*b == 0 || *b == '=') { /* End of option on command-line */ cur_prefix = a - opt->longname; if (!*a) { /* Matches end of option name */ best_match = i; longest_prefix = cur_prefix; goto finish; } if (cur_prefix == longest_prefix) { best_match = -1; /* Ambiguity */ } else if (cur_prefix > longest_prefix) { best_match = i; longest_prefix = cur_prefix; } break; } else if (*b != *a) { break; } } } finish: if (best_match >= 0) { opt = &ctx->options[best_match]; ctx->last_option_usage[best_match] = ctx->data; if (arg[longest_prefix] == '=') { if (nn_has_arg (opt)) { nn_process_option (ctx, best_match, arg + longest_prefix + 1); } else { nn_option_error ("does not accept argument", ctx, best_match); } } else { if (nn_has_arg (opt)) { if (nn_get_arg (ctx)) { nn_process_option (ctx, best_match, ctx->data); } else { nn_option_error ("requires an argument", ctx, best_match); } } else { nn_process_option (ctx, best_match, NULL); } } } else if (longest_prefix > 0) { nn_error_ambiguous_option (ctx); } else { nn_error_unknown_long_option (ctx); } } static void nn_parse_short_option (struct nn_parse_context *ctx) { int i; struct nn_option *opt; for (i = 0;; ++i) { opt = &ctx->options[i]; if (!opt->longname) break; if (!opt->shortname) continue; if (opt->shortname == *ctx->data) { ctx->last_option_usage[i] = ctx->data; if (nn_has_arg (opt)) { if (ctx->data[1]) { nn_process_option (ctx, i, ctx->data+1); } else { if (nn_get_arg (ctx)) { nn_process_option (ctx, i, ctx->data); } else { nn_option_error ("requires an argument", ctx, i); } } ctx->data = ""; /* end of short options anyway */ } else { nn_process_option (ctx, i, NULL); ctx->data += 1; } return; } } nn_error_unknown_short_option (ctx); } static void nn_parse_arg (struct nn_parse_context *ctx) { if (ctx->data[0] == '-') { /* an option */ if (ctx->data[1] == '-') { /* long option */ if (ctx->data[2] == 0) { /* end of options */ return; } nn_parse_long_option (ctx); } else { ctx->data += 1; /* Skip minus */ while (*ctx->data) { nn_parse_short_option (ctx); } } } else { nn_error_unexpected_argument (ctx); } } void nn_check_requires (struct nn_parse_context *ctx) { int i; struct nn_option *opt; for (i = 0;; ++i) { opt = &ctx->options[i]; if (!opt->longname) break; if (!ctx->last_option_usage[i]) continue; if (opt->requires_mask && (opt->requires_mask & ctx->mask) != opt->requires_mask) { nn_option_requires (ctx, i); } } if ((ctx->requires & ctx->mask) != ctx->requires) { fprintf (stderr, "%s: At least one of the following required:\n", ctx->argv[0]); nn_print_requires (ctx, ctx->requires & ~ctx->mask); exit (1); } } void nn_parse_options (struct nn_commandline *cline, void *target, int argc, char **argv) { struct nn_parse_context ctx; int num_options; ctx.def = cline; ctx.options = cline->options; ctx.target = target; ctx.argc = argc; ctx.argv = argv; ctx.requires = cline->required_options; for (num_options = 0; ctx.options[num_options].longname; ++num_options); ctx.last_option_usage = calloc (sizeof (char *), num_options); if (!ctx.last_option_usage) nn_memory_error (&ctx); ctx.mask = 0; ctx.args_left = argc - 1; ctx.arg = argv; nn_parse_arg0 (&ctx); while (nn_get_arg (&ctx)) { nn_parse_arg (&ctx); } nn_check_requires (&ctx); free (ctx.last_option_usage); } void nn_free_options (struct nn_commandline *cline, void *target) { int i, j; struct nn_option *opt; struct nn_blob *blob; struct nn_string_list *lst; for (i = 0;; ++i) { opt = &cline->options[i]; if (!opt->longname) break; switch(opt->type) { case NN_OPT_LIST_APPEND: case NN_OPT_LIST_APPEND_FMT: lst = (struct nn_string_list *)(((char *)target) + opt->offset); if(lst->items) { free(lst->items); lst->items = NULL; } if(lst->to_free) { for(j = 0; j < lst->to_free_num; ++j) { free(lst->to_free[j]); } free(lst->to_free); lst->to_free = NULL; } break; case NN_OPT_READ_FILE: case NN_OPT_BLOB: blob = (struct nn_blob *)(((char *)target) + opt->offset); if(blob->need_free && blob->data) { free(blob->data); blob->need_free = 0; } break; default: break; } } } nanomsg-0.8-beta/tools/options.h0000664000175000017500000000505012623652600017646 0ustar00travistravis00000000000000/* Copyright (c) 2013 Insollo Entertainment, LLC. 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. */ #ifndef NN_OPTIONS_HEADER #define NN_OPTIONS_HEADER enum nn_option_type { NN_OPT_HELP, NN_OPT_INT, NN_OPT_INCREMENT, NN_OPT_DECREMENT, NN_OPT_ENUM, NN_OPT_SET_ENUM, NN_OPT_STRING, NN_OPT_BLOB, NN_OPT_FLOAT, NN_OPT_LIST_APPEND, NN_OPT_LIST_APPEND_FMT, NN_OPT_READ_FILE }; struct nn_option { /* Option names */ char *longname; char shortname; char *arg0name; /* Parsing specification */ enum nn_option_type type; int offset; /* offsetof() where to store the value */ const void *pointer; /* type specific pointer */ /* Conflict mask for options */ unsigned long mask_set; unsigned long conflicts_mask; unsigned long requires_mask; /* Group and description for --help */ char *group; char *metavar; char *description; }; struct nn_commandline { char *short_description; char *long_description; struct nn_option *options; int required_options; }; struct nn_enum_item { char *name; int value; }; struct nn_string_list { char **items; char **to_free; int num; int to_free_num; }; struct nn_blob { char *data; int length; int need_free; }; void nn_parse_options (struct nn_commandline *cline, void *target, int argc, char **argv); void nn_free_options (struct nn_commandline *cline, void *target); #endif /* NN_OPTIONS_HEADER */ nanomsg-0.8-beta/tools/tcpmuxd.c0000664000175000017500000000344412623652600017637 0ustar00travistravis00000000000000/* Copyright (c) 2014 Martin Sustrik 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 "../src/nn.h" #include "../src/utils/err.h" #include "../src/utils/sleep.h" #include #include int main (int argc, const char *argv []) { int rc; int port; /* Parse the command line arguments. */ if (argc != 2) { fprintf (stderr, "usage: tcpmuxd \n"); return 1; } /* TODO: Use strtol here to detect malformed port numbers. */ port = atoi (argv [1]); /* Start the daemon. */ rc = nn_tcpmuxd (port); errno_assert (rc == 0); /* Block the main thread forever so that deamon isn't killed immediately. */ while (1) { nn_sleep (24 * 60 * 60 * 1000); } } nanomsg-0.8-beta/README0000664000175000017500000000366312623652600015532 0ustar00travistravis00000000000000Welcome to nanomsg ------------------ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nanomsg/nanomsg/blob/master/COPYING) [![Linux Status](https://img.shields.io/travis/nanomsg/nanomsg.svg?label=linux)](https://travis-ci.org/nanomsg/nanomsg) [![Windows Status](https://img.shields.io/appveyor/ci/gdamore/nanomsg.svg?label=windows)](https://ci.appveyor.com/project/gdamore/nanomsg) [![Gitter](https://img.shields.io/badge/gitter-join-brightgreen.svg)](https://gitter.im/nanomsg/nanomsg) nanomsg library is a simple high-performance implementation of several "scalability protocols". Scalability protocol's job is to define how multiple applications communicate to form a single distributed application. For more info check the web site: http://nanomsg.org Build it -------- 1. Download the package. 2. Unpack it. 3. Go to the root directory of the package. 4. sh autogen.sh 5. ./configure 6. make 7. make check 8. sudo make install 9. On Linux or other platforms which use ld.so for dynamic linking, run ldconfig or equivalent as root to update your system’s shared library cache. Build it on Windows ------------------- 1. Download the package. 2. Unpack it. 3. Go to the root directory of the package. 4. run "cmake ." 5. Open the nanomsg.sln file using MSVC IDE. 6. Build the entire solution. 7. Optionally, build RUN_TESTS project to run the test suite. Resources --------- Website: http://nanomsg.org Source code: https://github.com/nanomsg/nanomsg Documentation: http://nanomsg.org/documentation.html Bug tracker: https://github.com/nanomsg/nanomsg/issues Mailing list: nanomsg@freelists.org Subscribe to the list here: http://www.freelists.org/list/nanomsg IRC chatroom: channel #nanomsg at irc.freenode.net/8001 Gitter: [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/nanomsg/nanomsg?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) nanomsg-0.8-beta/configure.ac0000664000175000017500000003135512623652600017137 0ustar00travistravis00000000000000# Copyright (c) 2013 Luca Barbato # Copyright (c) 2013 GoPivotal, Inc. All rights reserved. # Copyright 2015 Garrett D'Amore # # 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. ################################################################################ # Start the configuration phase. # ################################################################################ AC_PREREQ([2.53]) AC_INIT([nanomsg], [m4_esyscmd([./package_version.sh])], [nanomsg@freelists.org], [nanomsg], [http://nanomsg.org/]) AC_CONFIG_SRCDIR([src/nn.h]) AM_INIT_AUTOMAKE([1.6 foreign subdir-objects tar-ustar dist-zip]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes]) ]) AC_CANONICAL_HOST ################################################################################ # Retrieve the versions. # ################################################################################ AC_PROG_SED AC_PROG_AWK NN_ABI_VERSION=m4_esyscmd([./abi_version.sh]) NN_PACKAGE_VERSION=m4_esyscmd([./package_version.sh]) NN_LIBTOOL_VERSION=m4_esyscmd([./abi_version.sh -libtool]) AC_SUBST(NN_ABI_VERSION) AC_SUBST(NN_PACKAGE_VERSION) AC_SUBST(NN_LIBTOOL_VERSION) AC_MSG_NOTICE([nanomsg package version: $NN_PACKAGE_VERSION]) AC_MSG_NOTICE([nanomsg ABI version: $NN_ABI_VERSION]) ################################################################################ # Check the compilers. # ################################################################################ AC_PROG_CC_C99 AM_PROG_CC_C_O ################################################################################ # Check whether GCC compiler is used. # ################################################################################ AS_IF([test x"$GCC" = xyes], [AC_DEFINE([NN_HAVE_GCC])] ) ################################################################################ # Check whether ICC compiler is used. # ################################################################################ AC_CACHE_CHECK([whether we are using ICC compiler], [ac_cv_icc_compiler], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [[ #ifndef __INTEL_COMPILER #error #endif ]])], [ac_icc_compiler=yes], [ac_icc_compiler=no]) ac_cv_icc_compiler=$ac_icc_compiler]) AS_IF([test x"$ac_cv_icc_compiler" = xyes], [AC_DEFINE([NN_HAVE_ICC])] ) ################################################################################ # Check whether Sun Studio compiler is used. # ################################################################################ AC_CACHE_CHECK([whether we are using Sun Studio compiler], [ac_cv_sun_studio_compiler], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [[ #ifndef __SUNPRO_C #error #endif ]])], [ac_sun_studio_compiler=yes], [ac_sun_studio_compiler=no]) ac_cv_sun_studio_compiler=$ac_sun_studio_compiler]) AS_IF([test x"$ac_cv_sun_studio_compiler" = xyes], [AC_DEFINE([NN_HAVE_SUN_STUDIO])] ) ################################################################################ # Check whether clang compiler is used. # ################################################################################ AC_CACHE_CHECK([whether we are using clang compiler], [ac_cv_clang_compiler], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [[ #ifndef __clang__ #error #endif ]])], [ac_clang_compiler=yes], [ac_clang_compiler=no]) ac_cv_clang_compiler=$ac_clang_compiler]) AS_IF([test x"$ac_cv_clang_compiler" = xyes], [AC_DEFINE([NN_HAVE_CLANG])] ) ################################################################################ # Check whether HP aCC compiler is used. # ################################################################################ AC_CACHE_CHECK([whether we are using HP aCC compiler], [ac_cv_hpacc_compiler], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [[ #ifndef __HP_cc #error #endif ]])], [ac_hpacc_compiler=yes], [ac_hpacc_compiler=no]) ac_cv_hpacc_compiler=$ac_hpacc_compiler]) AS_IF([test x"$ac_cv_hpacc_compiler" = xyes], [AC_DEFINE([NN_HAVE_HPACC])] ) ################################################################################ # If --enable-debug is specified set appropriate compiler options. # ################################################################################ AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [Enable debugging information [default=no]])]) if test "x$enable_debug" = "xyes"; then if test "x$GCC" = "xyes" -o \ "x$ac_cv_icc_compiler" = "xyes" -o \ "x$ac_cv_clang_compiler" = "xyes"; then CFLAGS="-g -O0 " elif test "x$ac_cv_sun_studio_compiler" = "xyes"; then CFLAGS="-g0 " elif test "x$ac_cv_hpacc_compiler" = "xyes"; then CFLAGS="-g +O0 " fi ORIG_CFLAGS="${CFLAGS:-none}" if test "x$ORIG_CFLAGS" != "xnone"; then CFLAGS="${CFLAGS} ${ORIG_CFLAGS}" fi AC_DEFINE([NN_DEBUG]) fi ################################################################################ # Build the documentation. # ################################################################################ AC_ARG_ENABLE([doc], AS_HELP_STRING([--enable-doc], [Build documentation [default=no]]) ) AS_IF([test x"$enable_doc" = "xyes"], [ AC_CHECK_PROGS([ASCIIDOC], [asciidoc]) AS_IF([test x"$ASCIIDOC" = "x"],[ AC_MSG_ERROR([Please install asciidoc to build the documentation]) ]) AC_CHECK_PROGS([XMLTO], [xmlto]) AS_IF([test x"$XMLTO" = "x"], [ AC_MSG_ERROR([Please install xmlto to build the documentation]) ]) AS_IF([test ! -d "doc"], [ AC_PROG_MKDIR_P AS_MKDIR_P("doc") ]) ]) AM_CONDITIONAL([DOC], [test x"$ASCIIDOC" != "x" -a x"$XMLTO" != "x" ]) ################################################################################ # Build nanocat # ################################################################################ AC_ARG_ENABLE([nanocat], AS_HELP_STRING([--enable-nanocat], [Build nanocat executable [default=yes]]) ) AC_ARG_ENABLE([symlinks], AS_HELP_STRING([--enable-symlinks], [Make nn_xxx symlinks for nanocat [default=yes]]) ) AS_IF([test x"$enable_nanocat" != "xno" -a x"$enable_symlinks" != x"no"], [ AC_PROG_LN_S ]) AM_CONDITIONAL([NANOCAT], [test x"$enable_nanocat" != "xno" ]) AM_CONDITIONAL([SYMLINKS], [test x"$enable_symlinks" != "xno" ]) ################################################################################ # Build tcpmuxd # ################################################################################ AC_ARG_ENABLE([tcpmuxd], AS_HELP_STRING([--enable-tcpmuxd], [Build tcpmuxd executable [default=yes]]) ) AS_IF([test x"$enable_tcpmuxd" != "xno"], [ AC_PROG_LN_S ]) AM_CONDITIONAL([TCPMUXD], [test x"$enable_tcpmuxd" != "xno" ]) ################################################################################ # Check which OS we are building for. # ################################################################################ AS_CASE([${host_os}], [*linux*], [AC_DEFINE([NN_HAVE_LINUX])], [*mingw32*], [ AC_DEFINE([NN_HAVE_WINDOWS]) AC_DEFINE([NN_HAVE_MINGW]) AC_DEFINE([_WIN32_WINNT],0x0600) LIBS="$LIBS -lws2_32 -lMswsock" ], [*darwin*], [AC_DEFINE([NN_HAVE_OSX])], [*freebsd*], [AC_DEFINE([NN_HAVE_FREEBSD])], [*netbsd*], [AC_DEFINE([NN_HAVE_NETBSD])], [*openbsd*], [AC_DEFINE([NN_HAVE_OPENBSD])], [*hpux*], [AC_DEFINE([NN_HAVE_HPUX])], [*solaris*], [ AC_DEFINE([NN_HAVE_SOLARIS]) AC_CHECK_LIB([socket], [socket]) AC_CHECK_LIB([nsl], [gethostbyname]) ], [*nto-qnx*], [ AC_DEFINE([NN_HAVE_QNX]) AC_CHECK_LIB([socket], [socket]) ] ) ################################################################################ # Feature checks. # ################################################################################ AX_PTHREAD([ LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CC="$PTHREAD_CC" ]) AC_CHECK_HEADERS([netinet/in.h]) AC_CHECK_HEADERS([netdb.h]) AC_CHECK_HEADERS([arpa/inet.h]) AC_CHECK_HEADERS([unistd.h]) AC_CHECK_HEADERS([sys/socket.h]) AC_CHECK_HEADERS([sys/ioctl.h]) AC_CHECK_HEADERS([stdint.h], [AC_DEFINE([NN_HAVE_STDINT])]) AC_CHECK_FUNCS([eventfd], [AC_DEFINE([NN_HAVE_EVENTFD])]) AC_CHECK_FUNCS([pipe], [AC_DEFINE([NN_HAVE_PIPE])]) AC_CHECK_FUNCS([pipe2], [ AC_DEFINE([NN_HAVE_PIPE2]) CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" ]) AC_CHECK_FUNCS([gethrtime], [AC_DEFINE([NN_HAVE_GETHRTIME])]) AC_MSG_CHECKING([for CLOCK_MONOTONIC]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]], [[ struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return 0; ]])], [ AC_MSG_RESULT([yes]) AC_DEFINE([NN_HAVE_CLOCK_MONOTONIC]) ], [ AC_MSG_RESULT([no]) ]) AC_CHECK_LIB([rt], [clock_gettime]) AC_CHECK_FUNCS([clock_gettime]) AC_CHECK_FUNCS([poll], [AC_DEFINE([NN_HAVE_POLL])]) AC_CHECK_FUNCS([epoll_create], [AC_DEFINE([NN_USE_EPOLL])], [ AC_CHECK_FUNCS([kqueue], [AC_DEFINE([NN_USE_KQUEUE])], [ AC_DEFINE([NN_USE_POLL]) ]) ]) AC_CHECK_FUNCS([accept4], [ AC_DEFINE([NN_HAVE_ACCEPT4]) CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" ]) AC_SEARCH_LIBS([getaddrinfo_a], [anl], [ AC_DEFINE([NN_HAVE_GETADDRINFO_A]) CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" ]) # Allow the use of getaddrinfo_a to be disabled. AC_ARG_ENABLE([getaddrinfo_a], AS_HELP_STRING([--enable-getaddrinfo_a], [Use getaddrinfo_a if available [default=yes]]) ) AS_IF([test x"$enable_getaddrinfo_a" == "xno"], [ AC_DEFINE([NN_DISABLE_GETADDRINFO_A]) ]) AC_SEARCH_LIBS([socketpair], [], [ AC_DEFINE([NN_HAVE_SOCKETPAIR]) ]) AC_SEARCH_LIBS([sem_wait], [rt pthread], [ AC_DEFINE([NN_HAVE_SEMAPHORE]) ]) AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ #include int main() { volatile uint32_t n = 0; __sync_fetch_and_add (&n, 1); __sync_fetch_and_sub (&n, 1); return 0; } ]])], [ AC_DEFINE([NN_HAVE_GCC_ATOMIC_BUILTINS]) ]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[#include ]], [[uint32_t value; atomic_cas_32 (&value, 0, 0); return 0;]])],[ AC_DEFINE([NN_HAVE_ATOMIC_SOLARIS])],[]) AC_MSG_CHECKING([for msghdr.msg_control]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]], [[ struct msghdr hdr; hdr.msg_control = 0; return 0; ]])], [ AC_MSG_RESULT([yes]) AC_DEFINE([NN_HAVE_MSG_CONTROL]) ], [ AC_MSG_RESULT([no]) ]) AS_IF([test x"$ac_cv_func_eventfd" = xyes], [ AC_DEFINE([NN_USE_EVENTFD])], [ AS_IF([test x"$ac_cv_func_pipe" = xyes], [ AC_DEFINE([NN_USE_PIPE])], [ AS_IF([test x"$ac_cv_func_socketpair" = xyes], [ AC_DEFINE([NN_USE_SOCKETPAIR])] ) ]) ]) LT_INIT DOLT ################################################################################ # Finish the configuration phase. # ################################################################################ AC_CONFIG_MACRO_DIR([m4]) AC_OUTPUT([ Makefile libnanomsg.pc ]) nanomsg-0.8-beta/aclocal.m40000664000175000017500000011371112623652610016507 0ustar00travistravis00000000000000# generated automatically by aclocal 1.11.3 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 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.68],, [m4_warning([this file was generated for autoconf 2.68. 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'.])]) # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 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 1 # 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.3], [], [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.3])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, 2011 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 1 # 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, # 2010, 2011 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 12 # 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'. rm -rf conftest.dir 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 ;; msvc7 | msvc7msys | 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='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])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, 2011 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 1 # 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])]) # 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 ]) # Copyright (C) 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_PROG_CC_C_O # -------------- # Like AC_PROG_CC_C_O, but changed for automake. AC_DEFUN([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC_C_O])dnl AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi dnl Make sure AC_PROG_CC is never called again, or it will override our dnl setting of CC. m4_define([AC_PROG_CC], [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) ]) # 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, 2011 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 1 # 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, 2010 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_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])]) # Copyright (C) 2001, 2003, 2005, 2011 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 1 # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # 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) 2009, 2011 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_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # (`yes' being less verbose, `no' or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [ --enable-silent-rules less verbose build output (undo: `make V=1') --disable-silent-rules verbose build output (undo: `make V=0')]) case $enable_silent_rules in yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few `make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using `$V' instead of `$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001, 2003, 2005, 2011 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 1 # 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, 2010 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 3 # _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, 2012 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. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} 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 m4_include([m4/ax_pthread.m4]) m4_include([m4/dolt.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) nanomsg-0.8-beta/Makefile.am0000664000175000017500000004131112623652600016676 0ustar00travistravis00000000000000# Copyright (c) 2013 Luca Barbato # # 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. ACLOCAL_AMFLAGS = -I m4 DISTCLEANFILES = @DOLT_CLEANFILES@ EXTRA_DIST = ################################################################################ # nanomsg library # ################################################################################ nnincludedir = $(includedir)/nanomsg nninclude_HEADERS = \ src/nn.h \ src/inproc.h \ src/ipc.h \ src/tcp.h \ src/ws.h \ src/pair.h \ src/pubsub.h \ src/reqrep.h \ src/pipeline.h \ src/survey.h \ src/bus.h \ src/tcpmux.h lib_LTLIBRARIES = libnanomsg.la NANOMSG_CORE = \ src/core/ep.h \ src/core/ep.c \ src/core/epbase.c \ src/core/global.h \ src/core/global.c \ src/core/pipe.c \ src/core/poll.c \ src/core/sock.h \ src/core/sock.c \ src/core/sockbase.c \ src/core/symbol.c NANOMSG_DEVICES =\ src/devices/device.c \ src/devices/device.h \ src/devices/tcpmuxd.c NANOMSG_AIO = \ src/aio/ctx.h \ src/aio/ctx.c \ src/aio/fsm.h \ src/aio/fsm.c \ src/aio/poller.h \ src/aio/poller.c \ src/aio/poller_epoll.h \ src/aio/poller_epoll.inc \ src/aio/poller_kqueue.h \ src/aio/poller_kqueue.inc \ src/aio/poller_poll.h \ src/aio/poller_poll.inc \ src/aio/pool.h \ src/aio/pool.c \ src/aio/timer.h \ src/aio/timer.c \ src/aio/timerset.h \ src/aio/timerset.c \ src/aio/usock.h \ src/aio/usock.c \ src/aio/usock_posix.h \ src/aio/usock_posix.inc \ src/aio/usock_win.h \ src/aio/usock_win.inc \ src/aio/worker.h \ src/aio/worker.c \ src/aio/worker_posix.h \ src/aio/worker_posix.inc \ src/aio/worker_win.h \ src/aio/worker_win.inc NANOMSG_UTILS = \ src/utils/alloc.h \ src/utils/alloc.c \ src/utils/atomic.h \ src/utils/atomic.c \ src/utils/attr.h \ src/utils/chunk.h \ src/utils/chunk.c \ src/utils/chunkref.h \ src/utils/chunkref.c \ src/utils/clock.h \ src/utils/clock.c \ src/utils/closefd.h \ src/utils/closefd.c \ src/utils/cont.h \ src/utils/efd.h \ src/utils/efd.c \ src/utils/efd_eventfd.h \ src/utils/efd_eventfd.inc \ src/utils/efd_pipe.h \ src/utils/efd_pipe.inc \ src/utils/efd_socketpair.h \ src/utils/efd_socketpair.inc \ src/utils/efd_win.h \ src/utils/efd_win.inc \ src/utils/err.h \ src/utils/err.c \ src/utils/fast.h \ src/utils/fd.h \ src/utils/glock.h \ src/utils/glock.c \ src/utils/hash.h \ src/utils/hash.c \ src/utils/int.h \ src/utils/list.h \ src/utils/list.c \ src/utils/msg.h \ src/utils/msg.c \ src/utils/mutex.h \ src/utils/mutex.c \ src/utils/queue.h \ src/utils/queue.c \ src/utils/random.h \ src/utils/random.c \ src/utils/sem.h \ src/utils/sem.c \ src/utils/sleep.h \ src/utils/sleep.c \ src/utils/stopwatch.h \ src/utils/stopwatch.c \ src/utils/thread.h \ src/utils/thread.c \ src/utils/thread_posix.h \ src/utils/thread_posix.inc \ src/utils/thread_win.h \ src/utils/thread_win.inc \ src/utils/win.h \ src/utils/wire.h \ src/utils/wire.c PROTOCOLS_UTILS = \ src/protocols/utils/dist.h \ src/protocols/utils/dist.c \ src/protocols/utils/excl.h \ src/protocols/utils/excl.c \ src/protocols/utils/fq.h \ src/protocols/utils/fq.c \ src/protocols/utils/lb.h \ src/protocols/utils/lb.c \ src/protocols/utils/priolist.h \ src/protocols/utils/priolist.c PROTOCOLS_BUS = \ src/protocols/bus/bus.h \ src/protocols/bus/bus.c \ src/protocols/bus/xbus.h \ src/protocols/bus/xbus.c PROTOCOLS_PIPELINE = \ src/protocols/pipeline/push.h \ src/protocols/pipeline/push.c \ src/protocols/pipeline/pull.h \ src/protocols/pipeline/pull.c \ src/protocols/pipeline/xpull.h \ src/protocols/pipeline/xpull.c \ src/protocols/pipeline/xpush.h \ src/protocols/pipeline/xpush.c PROTOCOLS_PAIR = \ src/protocols/pair/pair.h \ src/protocols/pair/pair.c \ src/protocols/pair/xpair.h \ src/protocols/pair/xpair.c PROTOCOLS_PUBSUB = \ src/protocols/pubsub/pub.h \ src/protocols/pubsub/pub.c \ src/protocols/pubsub/sub.h \ src/protocols/pubsub/sub.c \ src/protocols/pubsub/trie.h \ src/protocols/pubsub/trie.c \ src/protocols/pubsub/xpub.h \ src/protocols/pubsub/xpub.c \ src/protocols/pubsub/xsub.h \ src/protocols/pubsub/xsub.c PROTOCOLS_REQREP = \ src/protocols/reqrep/req.h \ src/protocols/reqrep/req.c \ src/protocols/reqrep/rep.h \ src/protocols/reqrep/rep.c \ src/protocols/reqrep/task.h \ src/protocols/reqrep/task.c \ src/protocols/reqrep/xrep.h \ src/protocols/reqrep/xrep.c \ src/protocols/reqrep/xreq.h \ src/protocols/reqrep/xreq.c PROTOCOLS_SURVEY = \ src/protocols/survey/respondent.h \ src/protocols/survey/respondent.c \ src/protocols/survey/surveyor.h \ src/protocols/survey/surveyor.c \ src/protocols/survey/xrespondent.h \ src/protocols/survey/xrespondent.c \ src/protocols/survey/xsurveyor.h \ src/protocols/survey/xsurveyor.c NANOMSG_PROTOCOLS = \ $(PROTOCOLS_BUS) \ $(PROTOCOLS_PIPELINE) \ $(PROTOCOLS_PAIR) \ $(PROTOCOLS_PUBSUB) \ $(PROTOCOLS_REQREP) \ $(PROTOCOLS_SURVEY) \ $(PROTOCOLS_UTILS) TRANSPORTS_UTILS = \ src/transports/utils/backoff.h \ src/transports/utils/backoff.c \ src/transports/utils/dns.h \ src/transports/utils/dns.c \ src/transports/utils/dns_getaddrinfo.h \ src/transports/utils/dns_getaddrinfo.inc \ src/transports/utils/dns_getaddrinfo_a.h \ src/transports/utils/dns_getaddrinfo_a.inc \ src/transports/utils/iface.h \ src/transports/utils/iface.c \ src/transports/utils/literal.h \ src/transports/utils/literal.c \ src/transports/utils/port.h \ src/transports/utils/port.c \ src/transports/utils/streamhdr.h \ src/transports/utils/streamhdr.c \ src/transports/utils/base64.h \ src/transports/utils/base64.c TRANSPORTS_INPROC = \ src/transports/inproc/binproc.h \ src/transports/inproc/binproc.c \ src/transports/inproc/cinproc.h \ src/transports/inproc/cinproc.c \ src/transports/inproc/inproc.h \ src/transports/inproc/inproc.c \ src/transports/inproc/ins.h \ src/transports/inproc/ins.c \ src/transports/inproc/msgqueue.h \ src/transports/inproc/msgqueue.c \ src/transports/inproc/sinproc.h \ src/transports/inproc/sinproc.c TRANSPORTS_IPC = \ src/transports/ipc/aipc.h \ src/transports/ipc/aipc.c \ src/transports/ipc/bipc.h \ src/transports/ipc/bipc.c \ src/transports/ipc/cipc.h \ src/transports/ipc/cipc.c \ src/transports/ipc/ipc.h \ src/transports/ipc/ipc.c \ src/transports/ipc/sipc.h \ src/transports/ipc/sipc.c TRANSPORTS_TCP = \ src/transports/tcp/atcp.h \ src/transports/tcp/atcp.c \ src/transports/tcp/btcp.h \ src/transports/tcp/btcp.c \ src/transports/tcp/ctcp.h \ src/transports/tcp/ctcp.c \ src/transports/tcp/stcp.h \ src/transports/tcp/stcp.c \ src/transports/tcp/tcp.h \ src/transports/tcp/tcp.c TRANSPORTS_WS = \ src/transports/ws/aws.h \ src/transports/ws/aws.c \ src/transports/ws/bws.h \ src/transports/ws/bws.c \ src/transports/ws/cws.h \ src/transports/ws/cws.c \ src/transports/ws/sws.h \ src/transports/ws/sws.c \ src/transports/ws/ws.h \ src/transports/ws/ws.c \ src/transports/ws/ws_handshake.h \ src/transports/ws/ws_handshake.c \ src/transports/ws/sha1.h \ src/transports/ws/sha1.c TRANSPORTS_TCPMUX = \ src/transports/tcpmux/atcpmux.h \ src/transports/tcpmux/atcpmux.c \ src/transports/tcpmux/btcpmux.h \ src/transports/tcpmux/btcpmux.c \ src/transports/tcpmux/ctcpmux.h \ src/transports/tcpmux/ctcpmux.c \ src/transports/tcpmux/stcpmux.h \ src/transports/tcpmux/stcpmux.c \ src/transports/tcpmux/tcpmux.h \ src/transports/tcpmux/tcpmux.c NANOMSG_TRANSPORTS = \ $(TRANSPORTS_UTILS) \ $(TRANSPORTS_INPROC) \ $(TRANSPORTS_IPC) \ $(TRANSPORTS_TCP) \ $(TRANSPORTS_WS) \ $(TRANSPORTS_TCPMUX) libnanomsg_la_SOURCES = \ src/transport.h \ src/protocol.h \ $(NANOMSG_CORE) \ $(NANOMSG_AIO) \ $(NANOMSG_UTILS) \ $(NANOMSG_PROTOCOLS) \ $(NANOMSG_TRANSPORTS) \ $(NANOMSG_DEVICES) pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libnanomsg.pc libnanomsg_la_LDFLAGS = -no-undefined -version-info @NN_LIBTOOL_VERSION@ libnanomsg_la_CFLAGS = -DNN_EXPORTS ################################################################################ # documentation # ################################################################################ # Source files. MAN7 = \ doc/nanomsg.txt \ doc/nn_pair.txt \ doc/nn_reqrep.txt \ doc/nn_pubsub.txt \ doc/nn_survey.txt \ doc/nn_pipeline.txt \ doc/nn_bus.txt \ doc/nn_inproc.txt \ doc/nn_ipc.txt \ doc/nn_tcp.txt \ doc/nn_tcpmux.txt \ doc/nn_ws.txt \ doc/nn_env.txt MAN3 = \ doc/nn_errno.txt \ doc/nn_strerror.txt \ doc/nn_symbol.txt \ doc/nn_symbol_info.txt \ doc/nn_term.txt \ doc/nn_allocmsg.txt \ doc/nn_reallocmsg.txt \ doc/nn_freemsg.txt \ doc/nn_socket.txt \ doc/nn_close.txt \ doc/nn_getsockopt.txt \ doc/nn_setsockopt.txt \ doc/nn_bind.txt \ doc/nn_connect.txt \ doc/nn_shutdown.txt \ doc/nn_send.txt \ doc/nn_recv.txt \ doc/nn_sendmsg.txt \ doc/nn_recvmsg.txt \ doc/nn_device.txt \ doc/nn_cmsg.txt \ doc/nn_poll.txt MAN1 = \ doc/nanocat.txt \ doc/tcpmuxd.txt if DOC # Build instructions. .txt.xml: $(AM_V_GEN)$(ASCIIDOC) -d manpage -b docbook \ -f $(abs_srcdir)/doc/asciidoc.conf \ -aversion=@NN_PACKAGE_VERSION@ -o $@ $< SUFFIXES = .1 .3 .7 .1.html .3.html .7.html .xml.1: $(AM_V_GEN)$(XMLTO) -o doc man $< .xml.3: $(AM_V_GEN)$(XMLTO) -o doc man $< .xml.7: $(AM_V_GEN)$(XMLTO) -o doc man $< .txt.1.html: $(AM_V_GEN)$(ASCIIDOC) -d manpage -b xhtml11 \ -a stylesheet=$(abs_srcdir)/doc/htmldoc.css \ -f $(abs_srcdir)/doc/asciidoc.conf \ -aversion=@NN_PACKAGE_VERSION@ -o $@ $< .txt.3.html: $(AM_V_GEN)$(ASCIIDOC) -d manpage -b xhtml11 \ -a stylesheet=$(abs_srcdir)/doc/htmldoc.css \ -f $(abs_srcdir)/doc/asciidoc.conf \ -aversion=@NN_PACKAGE_VERSION@ -o $@ $< .txt.7.html: $(AM_V_GEN)$(ASCIIDOC) -d manpage -b xhtml11 \ -a stylesheet=$(abs_srcdir)/doc/htmldoc.css \ -f $(abs_srcdir)/doc/asciidoc.conf \ -aversion=@NN_PACKAGE_VERSION@ -o $@ $< # Cause man pages to be generated and installed. dist_man1_MANS = $(MAN1:%.txt=%.1) dist_man3_MANS = $(MAN3:%.txt=%.3) dist_man7_MANS = $(MAN7:%.txt=%.7) # Cause HTML docs to be generated. html_DATA = $(MAN1:%.txt=%.1.html) $(MAN3:%.txt=%.3.html) $(MAN7:%.txt=%.7.html) # Extra files to be cleaned. CLEANFILES = $(MAN1:%.txt=%.1) $(MAN3:%.txt=%.3) $(MAN7:%.txt=%.7) \ $(MAN1:%.txt=%.1.html) $(MAN3:%.txt=%.3.html) $(MAN7:%.txt=%.7.html) endif # Extra files to be included into the source package. EXTRA_DIST += doc/asciidoc.conf doc/htmldoc.css $(MAN1) $(MAN3) $(MAN7) ################################################################################ # performance tests # ################################################################################ noinst_PROGRAMS = \ perf/inproc_lat \ perf/inproc_thr \ perf/local_lat \ perf/remote_lat \ perf/local_thr \ perf/remote_thr LDADD = libnanomsg.la ################################################################################ # automated tests # ################################################################################ TRANSPORT_TESTS = \ tests/inproc \ tests/inproc_shutdown \ tests/ipc \ tests/ipc_shutdown \ tests/ipc_stress \ tests/tcp \ tests/tcp_shutdown \ tests/ws \ tests/tcpmux PROTOCOL_TESTS = \ tests/pair \ tests/pubsub \ tests/reqrep \ tests/pipeline \ tests/survey \ tests/bus FEATURE_TESTS = \ tests/async_shutdown \ tests/block \ tests/term \ tests/timeo \ tests/iovec \ tests/msg \ tests/prio \ tests/poll \ tests/device \ tests/device4 \ tests/device5 \ tests/emfile \ tests/domain \ tests/trie \ tests/list \ tests/hash \ tests/symbol \ tests/separation \ tests/zerocopy \ tests/shutdown \ tests/cmsg \ tests/bug328 EXTRA_DIST += tests/testutil.h check_PROGRAMS = \ $(TRANSPORT_TESTS) \ $(PROTOCOL_TESTS) \ $(FEATURE_TESTS) TESTS = $(check_PROGRAMS) ################################################################################ # tools # ################################################################################ bin_PROGRAMS = nanocat_SOURCES = \ tools/nanocat.c \ tools/options.c \ tools/options.h if NANOCAT bin_PROGRAMS += nanocat endif #NANOCAT tcpmuxd_SOURCES = \ tools/tcpmuxd.c if TCPMUXD bin_PROGRAMS += tcpmuxd endif #TCPMUXD ################################################################################ # RFCs # ################################################################################ EXTRA_DIST += \ ./rfc/sp-protocol-ids-01.txt \ ./rfc/sp-tcp-mapping-01.txt \ ./rfc/sp-udp-mapping-01.txt \ ./rfc/sp-tls-mapping-01.txt \ ./rfc/sp-request-reply-01.txt ################################################################################ # additional packaging-related stuff # ################################################################################ # Generate ChangeLog file from git. # Also, there's no git availabe when building from the source package and # thus no way to obtain package version. Therefore, package version is # saved into a file when building a source package. dist-hook: $(srcdir)/package_version.sh > $(distdir)/.version if NANOCAT if SYMLINKS install-exec-hook: cd $(DESTDIR)$(bindir) && \ $(LN_S) -f nanocat nn_push$(EXEEXT) && \ $(LN_S) -f nanocat nn_pull$(EXEEXT) && \ $(LN_S) -f nanocat nn_pub$(EXEEXT) && \ $(LN_S) -f nanocat nn_sub$(EXEEXT) && \ $(LN_S) -f nanocat nn_req$(EXEEXT) && \ $(LN_S) -f nanocat nn_rep$(EXEEXT) && \ $(LN_S) -f nanocat nn_surveyor$(EXEEXT) && \ $(LN_S) -f nanocat nn_respondent$(EXEEXT) && \ $(LN_S) -f nanocat nn_bus$(EXEEXT) && \ $(LN_S) -f nanocat nn_pair$(EXEEXT) uninstall-hook: cd $(DESTDIR)$(bindir) && \ rm -f nn_push$(EXEEXT) ; \ rm -f nn_pull$(EXEEXT) ; \ rm -f nn_pub$(EXEEXT) ; \ rm -f nn_sub$(EXEEXT) ; \ rm -f nn_req$(EXEEXT) ; \ rm -f nn_rep$(EXEEXT) ; \ rm -f nn_surveyor$(EXEEXT) ; \ rm -f nn_respondent$(EXEEXT) ; \ rm -f nn_bus$(EXEEXT) ; \ rm -f nn_pair$(EXEEXT) cd $(DESTDIR)$(libdir) && \ rm -f libnanomsg.* cd $(DESTDIR)$(includedir) && \ rm -rf nanomsg endif #SYMLINKS endif #NANOCAT EXTRA_DIST += \ ./abi_version.sh \ ./package_version.sh \ ./src/CMakeLists.txt \ ./CMakeLists.txt diagrams: -mkdir -p doc/diagrams $(abs_srcdir)/doc/diag.py $(DEFS) $(CPPFLAGS) \ $(shell clang -E - -v < /dev/null 2>&1 | \ sed -n '/#include src/core/$(am__dirstamp) src/core/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/core/$(DEPDIR) @: > src/core/$(DEPDIR)/$(am__dirstamp) src/core/libnanomsg_la-ep.lo: src/core/$(am__dirstamp) \ src/core/$(DEPDIR)/$(am__dirstamp) src/core/libnanomsg_la-epbase.lo: src/core/$(am__dirstamp) \ src/core/$(DEPDIR)/$(am__dirstamp) src/core/libnanomsg_la-global.lo: src/core/$(am__dirstamp) \ src/core/$(DEPDIR)/$(am__dirstamp) src/core/libnanomsg_la-pipe.lo: src/core/$(am__dirstamp) \ src/core/$(DEPDIR)/$(am__dirstamp) src/core/libnanomsg_la-poll.lo: src/core/$(am__dirstamp) \ src/core/$(DEPDIR)/$(am__dirstamp) src/core/libnanomsg_la-sock.lo: src/core/$(am__dirstamp) \ src/core/$(DEPDIR)/$(am__dirstamp) src/core/libnanomsg_la-sockbase.lo: src/core/$(am__dirstamp) \ src/core/$(DEPDIR)/$(am__dirstamp) src/core/libnanomsg_la-symbol.lo: src/core/$(am__dirstamp) \ src/core/$(DEPDIR)/$(am__dirstamp) src/aio/$(am__dirstamp): @$(MKDIR_P) src/aio @: > src/aio/$(am__dirstamp) src/aio/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/aio/$(DEPDIR) @: > src/aio/$(DEPDIR)/$(am__dirstamp) src/aio/libnanomsg_la-ctx.lo: src/aio/$(am__dirstamp) \ src/aio/$(DEPDIR)/$(am__dirstamp) src/aio/libnanomsg_la-fsm.lo: src/aio/$(am__dirstamp) \ src/aio/$(DEPDIR)/$(am__dirstamp) src/aio/libnanomsg_la-poller.lo: src/aio/$(am__dirstamp) \ src/aio/$(DEPDIR)/$(am__dirstamp) src/aio/libnanomsg_la-pool.lo: src/aio/$(am__dirstamp) \ src/aio/$(DEPDIR)/$(am__dirstamp) src/aio/libnanomsg_la-timer.lo: src/aio/$(am__dirstamp) \ src/aio/$(DEPDIR)/$(am__dirstamp) src/aio/libnanomsg_la-timerset.lo: src/aio/$(am__dirstamp) \ src/aio/$(DEPDIR)/$(am__dirstamp) src/aio/libnanomsg_la-usock.lo: src/aio/$(am__dirstamp) \ src/aio/$(DEPDIR)/$(am__dirstamp) src/aio/libnanomsg_la-worker.lo: src/aio/$(am__dirstamp) \ src/aio/$(DEPDIR)/$(am__dirstamp) src/utils/$(am__dirstamp): @$(MKDIR_P) src/utils @: > src/utils/$(am__dirstamp) src/utils/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/utils/$(DEPDIR) @: > src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-alloc.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-atomic.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-chunk.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-chunkref.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-clock.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-closefd.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-efd.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-err.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-glock.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-hash.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-list.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-msg.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-mutex.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-queue.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-random.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-sem.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-sleep.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-stopwatch.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-thread.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/utils/libnanomsg_la-wire.lo: src/utils/$(am__dirstamp) \ src/utils/$(DEPDIR)/$(am__dirstamp) src/protocols/bus/$(am__dirstamp): @$(MKDIR_P) src/protocols/bus @: > src/protocols/bus/$(am__dirstamp) src/protocols/bus/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/protocols/bus/$(DEPDIR) @: > src/protocols/bus/$(DEPDIR)/$(am__dirstamp) src/protocols/bus/libnanomsg_la-bus.lo: \ src/protocols/bus/$(am__dirstamp) \ src/protocols/bus/$(DEPDIR)/$(am__dirstamp) src/protocols/bus/libnanomsg_la-xbus.lo: \ src/protocols/bus/$(am__dirstamp) \ src/protocols/bus/$(DEPDIR)/$(am__dirstamp) src/protocols/pipeline/$(am__dirstamp): @$(MKDIR_P) src/protocols/pipeline @: > src/protocols/pipeline/$(am__dirstamp) src/protocols/pipeline/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/protocols/pipeline/$(DEPDIR) @: > src/protocols/pipeline/$(DEPDIR)/$(am__dirstamp) src/protocols/pipeline/libnanomsg_la-push.lo: \ src/protocols/pipeline/$(am__dirstamp) \ src/protocols/pipeline/$(DEPDIR)/$(am__dirstamp) src/protocols/pipeline/libnanomsg_la-pull.lo: \ src/protocols/pipeline/$(am__dirstamp) \ src/protocols/pipeline/$(DEPDIR)/$(am__dirstamp) src/protocols/pipeline/libnanomsg_la-xpull.lo: \ src/protocols/pipeline/$(am__dirstamp) \ src/protocols/pipeline/$(DEPDIR)/$(am__dirstamp) src/protocols/pipeline/libnanomsg_la-xpush.lo: \ src/protocols/pipeline/$(am__dirstamp) \ src/protocols/pipeline/$(DEPDIR)/$(am__dirstamp) src/protocols/pair/$(am__dirstamp): @$(MKDIR_P) src/protocols/pair @: > src/protocols/pair/$(am__dirstamp) src/protocols/pair/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/protocols/pair/$(DEPDIR) @: > src/protocols/pair/$(DEPDIR)/$(am__dirstamp) src/protocols/pair/libnanomsg_la-pair.lo: \ src/protocols/pair/$(am__dirstamp) \ src/protocols/pair/$(DEPDIR)/$(am__dirstamp) src/protocols/pair/libnanomsg_la-xpair.lo: \ src/protocols/pair/$(am__dirstamp) \ src/protocols/pair/$(DEPDIR)/$(am__dirstamp) src/protocols/pubsub/$(am__dirstamp): @$(MKDIR_P) src/protocols/pubsub @: > src/protocols/pubsub/$(am__dirstamp) src/protocols/pubsub/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/protocols/pubsub/$(DEPDIR) @: > src/protocols/pubsub/$(DEPDIR)/$(am__dirstamp) src/protocols/pubsub/libnanomsg_la-pub.lo: \ src/protocols/pubsub/$(am__dirstamp) \ src/protocols/pubsub/$(DEPDIR)/$(am__dirstamp) src/protocols/pubsub/libnanomsg_la-sub.lo: \ src/protocols/pubsub/$(am__dirstamp) \ src/protocols/pubsub/$(DEPDIR)/$(am__dirstamp) src/protocols/pubsub/libnanomsg_la-trie.lo: \ src/protocols/pubsub/$(am__dirstamp) \ src/protocols/pubsub/$(DEPDIR)/$(am__dirstamp) src/protocols/pubsub/libnanomsg_la-xpub.lo: \ src/protocols/pubsub/$(am__dirstamp) \ src/protocols/pubsub/$(DEPDIR)/$(am__dirstamp) src/protocols/pubsub/libnanomsg_la-xsub.lo: \ src/protocols/pubsub/$(am__dirstamp) \ src/protocols/pubsub/$(DEPDIR)/$(am__dirstamp) src/protocols/reqrep/$(am__dirstamp): @$(MKDIR_P) src/protocols/reqrep @: > src/protocols/reqrep/$(am__dirstamp) src/protocols/reqrep/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/protocols/reqrep/$(DEPDIR) @: > src/protocols/reqrep/$(DEPDIR)/$(am__dirstamp) src/protocols/reqrep/libnanomsg_la-req.lo: \ src/protocols/reqrep/$(am__dirstamp) \ src/protocols/reqrep/$(DEPDIR)/$(am__dirstamp) src/protocols/reqrep/libnanomsg_la-rep.lo: \ src/protocols/reqrep/$(am__dirstamp) \ src/protocols/reqrep/$(DEPDIR)/$(am__dirstamp) src/protocols/reqrep/libnanomsg_la-task.lo: \ src/protocols/reqrep/$(am__dirstamp) \ src/protocols/reqrep/$(DEPDIR)/$(am__dirstamp) src/protocols/reqrep/libnanomsg_la-xrep.lo: \ src/protocols/reqrep/$(am__dirstamp) \ src/protocols/reqrep/$(DEPDIR)/$(am__dirstamp) src/protocols/reqrep/libnanomsg_la-xreq.lo: \ src/protocols/reqrep/$(am__dirstamp) \ src/protocols/reqrep/$(DEPDIR)/$(am__dirstamp) src/protocols/survey/$(am__dirstamp): @$(MKDIR_P) src/protocols/survey @: > src/protocols/survey/$(am__dirstamp) src/protocols/survey/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/protocols/survey/$(DEPDIR) @: > src/protocols/survey/$(DEPDIR)/$(am__dirstamp) src/protocols/survey/libnanomsg_la-respondent.lo: \ src/protocols/survey/$(am__dirstamp) \ src/protocols/survey/$(DEPDIR)/$(am__dirstamp) src/protocols/survey/libnanomsg_la-surveyor.lo: \ src/protocols/survey/$(am__dirstamp) \ src/protocols/survey/$(DEPDIR)/$(am__dirstamp) src/protocols/survey/libnanomsg_la-xrespondent.lo: \ src/protocols/survey/$(am__dirstamp) \ src/protocols/survey/$(DEPDIR)/$(am__dirstamp) src/protocols/survey/libnanomsg_la-xsurveyor.lo: \ src/protocols/survey/$(am__dirstamp) \ src/protocols/survey/$(DEPDIR)/$(am__dirstamp) src/protocols/utils/$(am__dirstamp): @$(MKDIR_P) src/protocols/utils @: > src/protocols/utils/$(am__dirstamp) src/protocols/utils/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/protocols/utils/$(DEPDIR) @: > src/protocols/utils/$(DEPDIR)/$(am__dirstamp) src/protocols/utils/libnanomsg_la-dist.lo: \ src/protocols/utils/$(am__dirstamp) \ src/protocols/utils/$(DEPDIR)/$(am__dirstamp) src/protocols/utils/libnanomsg_la-excl.lo: \ src/protocols/utils/$(am__dirstamp) \ src/protocols/utils/$(DEPDIR)/$(am__dirstamp) src/protocols/utils/libnanomsg_la-fq.lo: \ src/protocols/utils/$(am__dirstamp) \ src/protocols/utils/$(DEPDIR)/$(am__dirstamp) src/protocols/utils/libnanomsg_la-lb.lo: \ src/protocols/utils/$(am__dirstamp) \ src/protocols/utils/$(DEPDIR)/$(am__dirstamp) src/protocols/utils/libnanomsg_la-priolist.lo: \ src/protocols/utils/$(am__dirstamp) \ src/protocols/utils/$(DEPDIR)/$(am__dirstamp) src/transports/utils/$(am__dirstamp): @$(MKDIR_P) src/transports/utils @: > src/transports/utils/$(am__dirstamp) src/transports/utils/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/transports/utils/$(DEPDIR) @: > src/transports/utils/$(DEPDIR)/$(am__dirstamp) src/transports/utils/libnanomsg_la-backoff.lo: \ src/transports/utils/$(am__dirstamp) \ src/transports/utils/$(DEPDIR)/$(am__dirstamp) src/transports/utils/libnanomsg_la-dns.lo: \ src/transports/utils/$(am__dirstamp) \ src/transports/utils/$(DEPDIR)/$(am__dirstamp) src/transports/utils/libnanomsg_la-iface.lo: \ src/transports/utils/$(am__dirstamp) \ src/transports/utils/$(DEPDIR)/$(am__dirstamp) src/transports/utils/libnanomsg_la-literal.lo: \ src/transports/utils/$(am__dirstamp) \ src/transports/utils/$(DEPDIR)/$(am__dirstamp) src/transports/utils/libnanomsg_la-port.lo: \ src/transports/utils/$(am__dirstamp) \ src/transports/utils/$(DEPDIR)/$(am__dirstamp) src/transports/utils/libnanomsg_la-streamhdr.lo: \ src/transports/utils/$(am__dirstamp) \ src/transports/utils/$(DEPDIR)/$(am__dirstamp) src/transports/utils/libnanomsg_la-base64.lo: \ src/transports/utils/$(am__dirstamp) \ src/transports/utils/$(DEPDIR)/$(am__dirstamp) src/transports/inproc/$(am__dirstamp): @$(MKDIR_P) src/transports/inproc @: > src/transports/inproc/$(am__dirstamp) src/transports/inproc/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/transports/inproc/$(DEPDIR) @: > src/transports/inproc/$(DEPDIR)/$(am__dirstamp) src/transports/inproc/libnanomsg_la-binproc.lo: \ src/transports/inproc/$(am__dirstamp) \ src/transports/inproc/$(DEPDIR)/$(am__dirstamp) src/transports/inproc/libnanomsg_la-cinproc.lo: \ src/transports/inproc/$(am__dirstamp) \ src/transports/inproc/$(DEPDIR)/$(am__dirstamp) src/transports/inproc/libnanomsg_la-inproc.lo: \ src/transports/inproc/$(am__dirstamp) \ src/transports/inproc/$(DEPDIR)/$(am__dirstamp) src/transports/inproc/libnanomsg_la-ins.lo: \ src/transports/inproc/$(am__dirstamp) \ src/transports/inproc/$(DEPDIR)/$(am__dirstamp) src/transports/inproc/libnanomsg_la-msgqueue.lo: \ src/transports/inproc/$(am__dirstamp) \ src/transports/inproc/$(DEPDIR)/$(am__dirstamp) src/transports/inproc/libnanomsg_la-sinproc.lo: \ src/transports/inproc/$(am__dirstamp) \ src/transports/inproc/$(DEPDIR)/$(am__dirstamp) src/transports/ipc/$(am__dirstamp): @$(MKDIR_P) src/transports/ipc @: > src/transports/ipc/$(am__dirstamp) src/transports/ipc/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/transports/ipc/$(DEPDIR) @: > src/transports/ipc/$(DEPDIR)/$(am__dirstamp) src/transports/ipc/libnanomsg_la-aipc.lo: \ src/transports/ipc/$(am__dirstamp) \ src/transports/ipc/$(DEPDIR)/$(am__dirstamp) src/transports/ipc/libnanomsg_la-bipc.lo: \ src/transports/ipc/$(am__dirstamp) \ src/transports/ipc/$(DEPDIR)/$(am__dirstamp) src/transports/ipc/libnanomsg_la-cipc.lo: \ src/transports/ipc/$(am__dirstamp) \ src/transports/ipc/$(DEPDIR)/$(am__dirstamp) src/transports/ipc/libnanomsg_la-ipc.lo: \ src/transports/ipc/$(am__dirstamp) \ src/transports/ipc/$(DEPDIR)/$(am__dirstamp) src/transports/ipc/libnanomsg_la-sipc.lo: \ src/transports/ipc/$(am__dirstamp) \ src/transports/ipc/$(DEPDIR)/$(am__dirstamp) src/transports/tcp/$(am__dirstamp): @$(MKDIR_P) src/transports/tcp @: > src/transports/tcp/$(am__dirstamp) src/transports/tcp/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/transports/tcp/$(DEPDIR) @: > src/transports/tcp/$(DEPDIR)/$(am__dirstamp) src/transports/tcp/libnanomsg_la-atcp.lo: \ src/transports/tcp/$(am__dirstamp) \ src/transports/tcp/$(DEPDIR)/$(am__dirstamp) src/transports/tcp/libnanomsg_la-btcp.lo: \ src/transports/tcp/$(am__dirstamp) \ src/transports/tcp/$(DEPDIR)/$(am__dirstamp) src/transports/tcp/libnanomsg_la-ctcp.lo: \ src/transports/tcp/$(am__dirstamp) \ src/transports/tcp/$(DEPDIR)/$(am__dirstamp) src/transports/tcp/libnanomsg_la-stcp.lo: \ src/transports/tcp/$(am__dirstamp) \ src/transports/tcp/$(DEPDIR)/$(am__dirstamp) src/transports/tcp/libnanomsg_la-tcp.lo: \ src/transports/tcp/$(am__dirstamp) \ src/transports/tcp/$(DEPDIR)/$(am__dirstamp) src/transports/ws/$(am__dirstamp): @$(MKDIR_P) src/transports/ws @: > src/transports/ws/$(am__dirstamp) src/transports/ws/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/transports/ws/$(DEPDIR) @: > src/transports/ws/$(DEPDIR)/$(am__dirstamp) src/transports/ws/libnanomsg_la-aws.lo: \ src/transports/ws/$(am__dirstamp) \ src/transports/ws/$(DEPDIR)/$(am__dirstamp) src/transports/ws/libnanomsg_la-bws.lo: \ src/transports/ws/$(am__dirstamp) \ src/transports/ws/$(DEPDIR)/$(am__dirstamp) src/transports/ws/libnanomsg_la-cws.lo: \ src/transports/ws/$(am__dirstamp) \ src/transports/ws/$(DEPDIR)/$(am__dirstamp) src/transports/ws/libnanomsg_la-sws.lo: \ src/transports/ws/$(am__dirstamp) \ src/transports/ws/$(DEPDIR)/$(am__dirstamp) src/transports/ws/libnanomsg_la-ws.lo: \ src/transports/ws/$(am__dirstamp) \ src/transports/ws/$(DEPDIR)/$(am__dirstamp) src/transports/ws/libnanomsg_la-ws_handshake.lo: \ src/transports/ws/$(am__dirstamp) \ src/transports/ws/$(DEPDIR)/$(am__dirstamp) src/transports/ws/libnanomsg_la-sha1.lo: \ src/transports/ws/$(am__dirstamp) \ src/transports/ws/$(DEPDIR)/$(am__dirstamp) src/transports/tcpmux/$(am__dirstamp): @$(MKDIR_P) src/transports/tcpmux @: > src/transports/tcpmux/$(am__dirstamp) src/transports/tcpmux/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/transports/tcpmux/$(DEPDIR) @: > src/transports/tcpmux/$(DEPDIR)/$(am__dirstamp) src/transports/tcpmux/libnanomsg_la-atcpmux.lo: \ src/transports/tcpmux/$(am__dirstamp) \ src/transports/tcpmux/$(DEPDIR)/$(am__dirstamp) src/transports/tcpmux/libnanomsg_la-btcpmux.lo: \ src/transports/tcpmux/$(am__dirstamp) \ src/transports/tcpmux/$(DEPDIR)/$(am__dirstamp) src/transports/tcpmux/libnanomsg_la-ctcpmux.lo: \ src/transports/tcpmux/$(am__dirstamp) \ src/transports/tcpmux/$(DEPDIR)/$(am__dirstamp) src/transports/tcpmux/libnanomsg_la-stcpmux.lo: \ src/transports/tcpmux/$(am__dirstamp) \ src/transports/tcpmux/$(DEPDIR)/$(am__dirstamp) src/transports/tcpmux/libnanomsg_la-tcpmux.lo: \ src/transports/tcpmux/$(am__dirstamp) \ src/transports/tcpmux/$(DEPDIR)/$(am__dirstamp) src/devices/$(am__dirstamp): @$(MKDIR_P) src/devices @: > src/devices/$(am__dirstamp) src/devices/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/devices/$(DEPDIR) @: > src/devices/$(DEPDIR)/$(am__dirstamp) src/devices/libnanomsg_la-device.lo: src/devices/$(am__dirstamp) \ src/devices/$(DEPDIR)/$(am__dirstamp) src/devices/libnanomsg_la-tcpmuxd.lo: src/devices/$(am__dirstamp) \ src/devices/$(DEPDIR)/$(am__dirstamp) libnanomsg.la: $(libnanomsg_la_OBJECTS) $(libnanomsg_la_DEPENDENCIES) $(EXTRA_libnanomsg_la_DEPENDENCIES) $(AM_V_CCLD)$(libnanomsg_la_LINK) -rpath $(libdir) $(libnanomsg_la_OBJECTS) $(libnanomsg_la_LIBADD) $(LIBS) install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list tools/$(am__dirstamp): @$(MKDIR_P) tools @: > tools/$(am__dirstamp) tools/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) tools/$(DEPDIR) @: > tools/$(DEPDIR)/$(am__dirstamp) tools/nanocat.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) tools/options.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) nanocat$(EXEEXT): $(nanocat_OBJECTS) $(nanocat_DEPENDENCIES) $(EXTRA_nanocat_DEPENDENCIES) @rm -f nanocat$(EXEEXT) $(AM_V_CCLD)$(LINK) $(nanocat_OBJECTS) $(nanocat_LDADD) $(LIBS) perf/$(am__dirstamp): @$(MKDIR_P) perf @: > perf/$(am__dirstamp) perf/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) perf/$(DEPDIR) @: > perf/$(DEPDIR)/$(am__dirstamp) perf/inproc_lat.$(OBJEXT): perf/$(am__dirstamp) \ perf/$(DEPDIR)/$(am__dirstamp) perf/inproc_lat$(EXEEXT): $(perf_inproc_lat_OBJECTS) $(perf_inproc_lat_DEPENDENCIES) $(EXTRA_perf_inproc_lat_DEPENDENCIES) perf/$(am__dirstamp) @rm -f perf/inproc_lat$(EXEEXT) $(AM_V_CCLD)$(LINK) $(perf_inproc_lat_OBJECTS) $(perf_inproc_lat_LDADD) $(LIBS) perf/inproc_thr.$(OBJEXT): perf/$(am__dirstamp) \ perf/$(DEPDIR)/$(am__dirstamp) perf/inproc_thr$(EXEEXT): $(perf_inproc_thr_OBJECTS) $(perf_inproc_thr_DEPENDENCIES) $(EXTRA_perf_inproc_thr_DEPENDENCIES) perf/$(am__dirstamp) @rm -f perf/inproc_thr$(EXEEXT) $(AM_V_CCLD)$(LINK) $(perf_inproc_thr_OBJECTS) $(perf_inproc_thr_LDADD) $(LIBS) perf/local_lat.$(OBJEXT): perf/$(am__dirstamp) \ perf/$(DEPDIR)/$(am__dirstamp) perf/local_lat$(EXEEXT): $(perf_local_lat_OBJECTS) $(perf_local_lat_DEPENDENCIES) $(EXTRA_perf_local_lat_DEPENDENCIES) perf/$(am__dirstamp) @rm -f perf/local_lat$(EXEEXT) $(AM_V_CCLD)$(LINK) $(perf_local_lat_OBJECTS) $(perf_local_lat_LDADD) $(LIBS) perf/local_thr.$(OBJEXT): perf/$(am__dirstamp) \ perf/$(DEPDIR)/$(am__dirstamp) perf/local_thr$(EXEEXT): $(perf_local_thr_OBJECTS) $(perf_local_thr_DEPENDENCIES) $(EXTRA_perf_local_thr_DEPENDENCIES) perf/$(am__dirstamp) @rm -f perf/local_thr$(EXEEXT) $(AM_V_CCLD)$(LINK) $(perf_local_thr_OBJECTS) $(perf_local_thr_LDADD) $(LIBS) perf/remote_lat.$(OBJEXT): perf/$(am__dirstamp) \ perf/$(DEPDIR)/$(am__dirstamp) perf/remote_lat$(EXEEXT): $(perf_remote_lat_OBJECTS) $(perf_remote_lat_DEPENDENCIES) $(EXTRA_perf_remote_lat_DEPENDENCIES) perf/$(am__dirstamp) @rm -f perf/remote_lat$(EXEEXT) $(AM_V_CCLD)$(LINK) $(perf_remote_lat_OBJECTS) $(perf_remote_lat_LDADD) $(LIBS) perf/remote_thr.$(OBJEXT): perf/$(am__dirstamp) \ perf/$(DEPDIR)/$(am__dirstamp) perf/remote_thr$(EXEEXT): $(perf_remote_thr_OBJECTS) $(perf_remote_thr_DEPENDENCIES) $(EXTRA_perf_remote_thr_DEPENDENCIES) perf/$(am__dirstamp) @rm -f perf/remote_thr$(EXEEXT) $(AM_V_CCLD)$(LINK) $(perf_remote_thr_OBJECTS) $(perf_remote_thr_LDADD) $(LIBS) tools/tcpmuxd.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) tcpmuxd$(EXEEXT): $(tcpmuxd_OBJECTS) $(tcpmuxd_DEPENDENCIES) $(EXTRA_tcpmuxd_DEPENDENCIES) @rm -f tcpmuxd$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tcpmuxd_OBJECTS) $(tcpmuxd_LDADD) $(LIBS) tests/$(am__dirstamp): @$(MKDIR_P) tests @: > tests/$(am__dirstamp) tests/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) tests/$(DEPDIR) @: > tests/$(DEPDIR)/$(am__dirstamp) tests/async_shutdown.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/async_shutdown$(EXEEXT): $(tests_async_shutdown_OBJECTS) $(tests_async_shutdown_DEPENDENCIES) $(EXTRA_tests_async_shutdown_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/async_shutdown$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_async_shutdown_OBJECTS) $(tests_async_shutdown_LDADD) $(LIBS) tests/block.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/block$(EXEEXT): $(tests_block_OBJECTS) $(tests_block_DEPENDENCIES) $(EXTRA_tests_block_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/block$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_block_OBJECTS) $(tests_block_LDADD) $(LIBS) tests/bug328.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/bug328$(EXEEXT): $(tests_bug328_OBJECTS) $(tests_bug328_DEPENDENCIES) $(EXTRA_tests_bug328_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/bug328$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_bug328_OBJECTS) $(tests_bug328_LDADD) $(LIBS) tests/bus.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/bus$(EXEEXT): $(tests_bus_OBJECTS) $(tests_bus_DEPENDENCIES) $(EXTRA_tests_bus_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/bus$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_bus_OBJECTS) $(tests_bus_LDADD) $(LIBS) tests/cmsg.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/cmsg$(EXEEXT): $(tests_cmsg_OBJECTS) $(tests_cmsg_DEPENDENCIES) $(EXTRA_tests_cmsg_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/cmsg$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_cmsg_OBJECTS) $(tests_cmsg_LDADD) $(LIBS) tests/device.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/device$(EXEEXT): $(tests_device_OBJECTS) $(tests_device_DEPENDENCIES) $(EXTRA_tests_device_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/device$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_device_OBJECTS) $(tests_device_LDADD) $(LIBS) tests/device4.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/device4$(EXEEXT): $(tests_device4_OBJECTS) $(tests_device4_DEPENDENCIES) $(EXTRA_tests_device4_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/device4$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_device4_OBJECTS) $(tests_device4_LDADD) $(LIBS) tests/device5.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/device5$(EXEEXT): $(tests_device5_OBJECTS) $(tests_device5_DEPENDENCIES) $(EXTRA_tests_device5_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/device5$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_device5_OBJECTS) $(tests_device5_LDADD) $(LIBS) tests/domain.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/domain$(EXEEXT): $(tests_domain_OBJECTS) $(tests_domain_DEPENDENCIES) $(EXTRA_tests_domain_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/domain$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_domain_OBJECTS) $(tests_domain_LDADD) $(LIBS) tests/emfile.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/emfile$(EXEEXT): $(tests_emfile_OBJECTS) $(tests_emfile_DEPENDENCIES) $(EXTRA_tests_emfile_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/emfile$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_emfile_OBJECTS) $(tests_emfile_LDADD) $(LIBS) tests/hash.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/hash$(EXEEXT): $(tests_hash_OBJECTS) $(tests_hash_DEPENDENCIES) $(EXTRA_tests_hash_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/hash$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_hash_OBJECTS) $(tests_hash_LDADD) $(LIBS) tests/inproc.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/inproc$(EXEEXT): $(tests_inproc_OBJECTS) $(tests_inproc_DEPENDENCIES) $(EXTRA_tests_inproc_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/inproc$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_inproc_OBJECTS) $(tests_inproc_LDADD) $(LIBS) tests/inproc_shutdown.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/inproc_shutdown$(EXEEXT): $(tests_inproc_shutdown_OBJECTS) $(tests_inproc_shutdown_DEPENDENCIES) $(EXTRA_tests_inproc_shutdown_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/inproc_shutdown$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_inproc_shutdown_OBJECTS) $(tests_inproc_shutdown_LDADD) $(LIBS) tests/iovec.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/iovec$(EXEEXT): $(tests_iovec_OBJECTS) $(tests_iovec_DEPENDENCIES) $(EXTRA_tests_iovec_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/iovec$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_iovec_OBJECTS) $(tests_iovec_LDADD) $(LIBS) tests/ipc.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/ipc$(EXEEXT): $(tests_ipc_OBJECTS) $(tests_ipc_DEPENDENCIES) $(EXTRA_tests_ipc_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/ipc$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_ipc_OBJECTS) $(tests_ipc_LDADD) $(LIBS) tests/ipc_shutdown.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/ipc_shutdown$(EXEEXT): $(tests_ipc_shutdown_OBJECTS) $(tests_ipc_shutdown_DEPENDENCIES) $(EXTRA_tests_ipc_shutdown_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/ipc_shutdown$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_ipc_shutdown_OBJECTS) $(tests_ipc_shutdown_LDADD) $(LIBS) tests/ipc_stress.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/ipc_stress$(EXEEXT): $(tests_ipc_stress_OBJECTS) $(tests_ipc_stress_DEPENDENCIES) $(EXTRA_tests_ipc_stress_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/ipc_stress$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_ipc_stress_OBJECTS) $(tests_ipc_stress_LDADD) $(LIBS) tests/list.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/list$(EXEEXT): $(tests_list_OBJECTS) $(tests_list_DEPENDENCIES) $(EXTRA_tests_list_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/list$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_list_OBJECTS) $(tests_list_LDADD) $(LIBS) tests/msg.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/msg$(EXEEXT): $(tests_msg_OBJECTS) $(tests_msg_DEPENDENCIES) $(EXTRA_tests_msg_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/msg$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_msg_OBJECTS) $(tests_msg_LDADD) $(LIBS) tests/pair.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/pair$(EXEEXT): $(tests_pair_OBJECTS) $(tests_pair_DEPENDENCIES) $(EXTRA_tests_pair_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/pair$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_pair_OBJECTS) $(tests_pair_LDADD) $(LIBS) tests/pipeline.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/pipeline$(EXEEXT): $(tests_pipeline_OBJECTS) $(tests_pipeline_DEPENDENCIES) $(EXTRA_tests_pipeline_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/pipeline$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_pipeline_OBJECTS) $(tests_pipeline_LDADD) $(LIBS) tests/poll.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/poll$(EXEEXT): $(tests_poll_OBJECTS) $(tests_poll_DEPENDENCIES) $(EXTRA_tests_poll_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/poll$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_poll_OBJECTS) $(tests_poll_LDADD) $(LIBS) tests/prio.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/prio$(EXEEXT): $(tests_prio_OBJECTS) $(tests_prio_DEPENDENCIES) $(EXTRA_tests_prio_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/prio$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_prio_OBJECTS) $(tests_prio_LDADD) $(LIBS) tests/pubsub.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/pubsub$(EXEEXT): $(tests_pubsub_OBJECTS) $(tests_pubsub_DEPENDENCIES) $(EXTRA_tests_pubsub_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/pubsub$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_pubsub_OBJECTS) $(tests_pubsub_LDADD) $(LIBS) tests/reqrep.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/reqrep$(EXEEXT): $(tests_reqrep_OBJECTS) $(tests_reqrep_DEPENDENCIES) $(EXTRA_tests_reqrep_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/reqrep$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_reqrep_OBJECTS) $(tests_reqrep_LDADD) $(LIBS) tests/separation.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/separation$(EXEEXT): $(tests_separation_OBJECTS) $(tests_separation_DEPENDENCIES) $(EXTRA_tests_separation_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/separation$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_separation_OBJECTS) $(tests_separation_LDADD) $(LIBS) tests/shutdown.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/shutdown$(EXEEXT): $(tests_shutdown_OBJECTS) $(tests_shutdown_DEPENDENCIES) $(EXTRA_tests_shutdown_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/shutdown$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_shutdown_OBJECTS) $(tests_shutdown_LDADD) $(LIBS) tests/survey.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/survey$(EXEEXT): $(tests_survey_OBJECTS) $(tests_survey_DEPENDENCIES) $(EXTRA_tests_survey_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/survey$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_survey_OBJECTS) $(tests_survey_LDADD) $(LIBS) tests/symbol.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/symbol$(EXEEXT): $(tests_symbol_OBJECTS) $(tests_symbol_DEPENDENCIES) $(EXTRA_tests_symbol_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/symbol$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_symbol_OBJECTS) $(tests_symbol_LDADD) $(LIBS) tests/tcp.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/tcp$(EXEEXT): $(tests_tcp_OBJECTS) $(tests_tcp_DEPENDENCIES) $(EXTRA_tests_tcp_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/tcp$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_tcp_OBJECTS) $(tests_tcp_LDADD) $(LIBS) tests/tcp_shutdown.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/tcp_shutdown$(EXEEXT): $(tests_tcp_shutdown_OBJECTS) $(tests_tcp_shutdown_DEPENDENCIES) $(EXTRA_tests_tcp_shutdown_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/tcp_shutdown$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_tcp_shutdown_OBJECTS) $(tests_tcp_shutdown_LDADD) $(LIBS) tests/tcpmux.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/tcpmux$(EXEEXT): $(tests_tcpmux_OBJECTS) $(tests_tcpmux_DEPENDENCIES) $(EXTRA_tests_tcpmux_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/tcpmux$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_tcpmux_OBJECTS) $(tests_tcpmux_LDADD) $(LIBS) tests/term.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/term$(EXEEXT): $(tests_term_OBJECTS) $(tests_term_DEPENDENCIES) $(EXTRA_tests_term_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/term$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_term_OBJECTS) $(tests_term_LDADD) $(LIBS) tests/timeo.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/timeo$(EXEEXT): $(tests_timeo_OBJECTS) $(tests_timeo_DEPENDENCIES) $(EXTRA_tests_timeo_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/timeo$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_timeo_OBJECTS) $(tests_timeo_LDADD) $(LIBS) tests/trie.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/trie$(EXEEXT): $(tests_trie_OBJECTS) $(tests_trie_DEPENDENCIES) $(EXTRA_tests_trie_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/trie$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_trie_OBJECTS) $(tests_trie_LDADD) $(LIBS) tests/ws.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/ws$(EXEEXT): $(tests_ws_OBJECTS) $(tests_ws_DEPENDENCIES) $(EXTRA_tests_ws_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/ws$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_ws_OBJECTS) $(tests_ws_LDADD) $(LIBS) tests/zerocopy.$(OBJEXT): tests/$(am__dirstamp) \ tests/$(DEPDIR)/$(am__dirstamp) tests/zerocopy$(EXEEXT): $(tests_zerocopy_OBJECTS) $(tests_zerocopy_DEPENDENCIES) $(EXTRA_tests_zerocopy_DEPENDENCIES) tests/$(am__dirstamp) @rm -f tests/zerocopy$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tests_zerocopy_OBJECTS) $(tests_zerocopy_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f perf/inproc_lat.$(OBJEXT) -rm -f perf/inproc_thr.$(OBJEXT) -rm -f perf/local_lat.$(OBJEXT) -rm -f perf/local_thr.$(OBJEXT) -rm -f perf/remote_lat.$(OBJEXT) -rm -f perf/remote_thr.$(OBJEXT) -rm -f src/aio/libnanomsg_la-ctx.$(OBJEXT) -rm -f src/aio/libnanomsg_la-ctx.lo -rm -f src/aio/libnanomsg_la-fsm.$(OBJEXT) -rm -f src/aio/libnanomsg_la-fsm.lo -rm -f src/aio/libnanomsg_la-poller.$(OBJEXT) -rm -f src/aio/libnanomsg_la-poller.lo -rm -f src/aio/libnanomsg_la-pool.$(OBJEXT) -rm -f src/aio/libnanomsg_la-pool.lo -rm -f src/aio/libnanomsg_la-timer.$(OBJEXT) -rm -f src/aio/libnanomsg_la-timer.lo -rm -f src/aio/libnanomsg_la-timerset.$(OBJEXT) -rm -f src/aio/libnanomsg_la-timerset.lo -rm -f src/aio/libnanomsg_la-usock.$(OBJEXT) -rm -f src/aio/libnanomsg_la-usock.lo -rm -f src/aio/libnanomsg_la-worker.$(OBJEXT) -rm -f src/aio/libnanomsg_la-worker.lo -rm -f src/core/libnanomsg_la-ep.$(OBJEXT) -rm -f src/core/libnanomsg_la-ep.lo -rm -f src/core/libnanomsg_la-epbase.$(OBJEXT) -rm -f src/core/libnanomsg_la-epbase.lo -rm -f src/core/libnanomsg_la-global.$(OBJEXT) -rm -f src/core/libnanomsg_la-global.lo -rm -f src/core/libnanomsg_la-pipe.$(OBJEXT) -rm -f src/core/libnanomsg_la-pipe.lo -rm -f src/core/libnanomsg_la-poll.$(OBJEXT) -rm -f src/core/libnanomsg_la-poll.lo -rm -f src/core/libnanomsg_la-sock.$(OBJEXT) -rm -f src/core/libnanomsg_la-sock.lo -rm -f src/core/libnanomsg_la-sockbase.$(OBJEXT) -rm -f src/core/libnanomsg_la-sockbase.lo -rm -f src/core/libnanomsg_la-symbol.$(OBJEXT) -rm -f src/core/libnanomsg_la-symbol.lo -rm -f src/devices/libnanomsg_la-device.$(OBJEXT) -rm -f src/devices/libnanomsg_la-device.lo -rm -f src/devices/libnanomsg_la-tcpmuxd.$(OBJEXT) -rm -f src/devices/libnanomsg_la-tcpmuxd.lo -rm -f src/protocols/bus/libnanomsg_la-bus.$(OBJEXT) -rm -f src/protocols/bus/libnanomsg_la-bus.lo -rm -f src/protocols/bus/libnanomsg_la-xbus.$(OBJEXT) -rm -f src/protocols/bus/libnanomsg_la-xbus.lo -rm -f src/protocols/pair/libnanomsg_la-pair.$(OBJEXT) -rm -f src/protocols/pair/libnanomsg_la-pair.lo -rm -f src/protocols/pair/libnanomsg_la-xpair.$(OBJEXT) -rm -f src/protocols/pair/libnanomsg_la-xpair.lo -rm -f src/protocols/pipeline/libnanomsg_la-pull.$(OBJEXT) -rm -f src/protocols/pipeline/libnanomsg_la-pull.lo -rm -f src/protocols/pipeline/libnanomsg_la-push.$(OBJEXT) -rm -f src/protocols/pipeline/libnanomsg_la-push.lo -rm -f src/protocols/pipeline/libnanomsg_la-xpull.$(OBJEXT) -rm -f src/protocols/pipeline/libnanomsg_la-xpull.lo -rm -f src/protocols/pipeline/libnanomsg_la-xpush.$(OBJEXT) -rm -f src/protocols/pipeline/libnanomsg_la-xpush.lo -rm -f src/protocols/pubsub/libnanomsg_la-pub.$(OBJEXT) -rm -f src/protocols/pubsub/libnanomsg_la-pub.lo -rm -f src/protocols/pubsub/libnanomsg_la-sub.$(OBJEXT) -rm -f src/protocols/pubsub/libnanomsg_la-sub.lo -rm -f src/protocols/pubsub/libnanomsg_la-trie.$(OBJEXT) -rm -f src/protocols/pubsub/libnanomsg_la-trie.lo -rm -f src/protocols/pubsub/libnanomsg_la-xpub.$(OBJEXT) -rm -f src/protocols/pubsub/libnanomsg_la-xpub.lo -rm -f src/protocols/pubsub/libnanomsg_la-xsub.$(OBJEXT) -rm -f src/protocols/pubsub/libnanomsg_la-xsub.lo -rm -f src/protocols/reqrep/libnanomsg_la-rep.$(OBJEXT) -rm -f src/protocols/reqrep/libnanomsg_la-rep.lo -rm -f src/protocols/reqrep/libnanomsg_la-req.$(OBJEXT) -rm -f src/protocols/reqrep/libnanomsg_la-req.lo -rm -f src/protocols/reqrep/libnanomsg_la-task.$(OBJEXT) -rm -f src/protocols/reqrep/libnanomsg_la-task.lo -rm -f src/protocols/reqrep/libnanomsg_la-xrep.$(OBJEXT) -rm -f src/protocols/reqrep/libnanomsg_la-xrep.lo -rm -f src/protocols/reqrep/libnanomsg_la-xreq.$(OBJEXT) -rm -f src/protocols/reqrep/libnanomsg_la-xreq.lo -rm -f src/protocols/survey/libnanomsg_la-respondent.$(OBJEXT) -rm -f src/protocols/survey/libnanomsg_la-respondent.lo -rm -f src/protocols/survey/libnanomsg_la-surveyor.$(OBJEXT) -rm -f src/protocols/survey/libnanomsg_la-surveyor.lo -rm -f src/protocols/survey/libnanomsg_la-xrespondent.$(OBJEXT) -rm -f src/protocols/survey/libnanomsg_la-xrespondent.lo -rm -f src/protocols/survey/libnanomsg_la-xsurveyor.$(OBJEXT) -rm -f src/protocols/survey/libnanomsg_la-xsurveyor.lo -rm -f src/protocols/utils/libnanomsg_la-dist.$(OBJEXT) -rm -f src/protocols/utils/libnanomsg_la-dist.lo -rm -f src/protocols/utils/libnanomsg_la-excl.$(OBJEXT) -rm -f src/protocols/utils/libnanomsg_la-excl.lo -rm -f src/protocols/utils/libnanomsg_la-fq.$(OBJEXT) -rm -f src/protocols/utils/libnanomsg_la-fq.lo -rm -f src/protocols/utils/libnanomsg_la-lb.$(OBJEXT) -rm -f src/protocols/utils/libnanomsg_la-lb.lo -rm -f src/protocols/utils/libnanomsg_la-priolist.$(OBJEXT) -rm -f src/protocols/utils/libnanomsg_la-priolist.lo -rm -f src/transports/inproc/libnanomsg_la-binproc.$(OBJEXT) -rm -f src/transports/inproc/libnanomsg_la-binproc.lo -rm -f src/transports/inproc/libnanomsg_la-cinproc.$(OBJEXT) -rm -f src/transports/inproc/libnanomsg_la-cinproc.lo -rm -f src/transports/inproc/libnanomsg_la-inproc.$(OBJEXT) -rm -f src/transports/inproc/libnanomsg_la-inproc.lo -rm -f src/transports/inproc/libnanomsg_la-ins.$(OBJEXT) -rm -f src/transports/inproc/libnanomsg_la-ins.lo -rm -f src/transports/inproc/libnanomsg_la-msgqueue.$(OBJEXT) -rm -f src/transports/inproc/libnanomsg_la-msgqueue.lo -rm -f src/transports/inproc/libnanomsg_la-sinproc.$(OBJEXT) -rm -f src/transports/inproc/libnanomsg_la-sinproc.lo -rm -f src/transports/ipc/libnanomsg_la-aipc.$(OBJEXT) -rm -f src/transports/ipc/libnanomsg_la-aipc.lo -rm -f src/transports/ipc/libnanomsg_la-bipc.$(OBJEXT) -rm -f src/transports/ipc/libnanomsg_la-bipc.lo -rm -f src/transports/ipc/libnanomsg_la-cipc.$(OBJEXT) -rm -f src/transports/ipc/libnanomsg_la-cipc.lo -rm -f src/transports/ipc/libnanomsg_la-ipc.$(OBJEXT) -rm -f src/transports/ipc/libnanomsg_la-ipc.lo -rm -f src/transports/ipc/libnanomsg_la-sipc.$(OBJEXT) -rm -f src/transports/ipc/libnanomsg_la-sipc.lo -rm -f src/transports/tcp/libnanomsg_la-atcp.$(OBJEXT) -rm -f src/transports/tcp/libnanomsg_la-atcp.lo -rm -f src/transports/tcp/libnanomsg_la-btcp.$(OBJEXT) -rm -f src/transports/tcp/libnanomsg_la-btcp.lo -rm -f src/transports/tcp/libnanomsg_la-ctcp.$(OBJEXT) -rm -f src/transports/tcp/libnanomsg_la-ctcp.lo -rm -f src/transports/tcp/libnanomsg_la-stcp.$(OBJEXT) -rm -f src/transports/tcp/libnanomsg_la-stcp.lo -rm -f src/transports/tcp/libnanomsg_la-tcp.$(OBJEXT) -rm -f src/transports/tcp/libnanomsg_la-tcp.lo -rm -f src/transports/tcpmux/libnanomsg_la-atcpmux.$(OBJEXT) -rm -f src/transports/tcpmux/libnanomsg_la-atcpmux.lo -rm -f src/transports/tcpmux/libnanomsg_la-btcpmux.$(OBJEXT) -rm -f src/transports/tcpmux/libnanomsg_la-btcpmux.lo -rm -f src/transports/tcpmux/libnanomsg_la-ctcpmux.$(OBJEXT) -rm -f src/transports/tcpmux/libnanomsg_la-ctcpmux.lo -rm -f src/transports/tcpmux/libnanomsg_la-stcpmux.$(OBJEXT) -rm -f src/transports/tcpmux/libnanomsg_la-stcpmux.lo -rm -f src/transports/tcpmux/libnanomsg_la-tcpmux.$(OBJEXT) -rm -f src/transports/tcpmux/libnanomsg_la-tcpmux.lo -rm -f src/transports/utils/libnanomsg_la-backoff.$(OBJEXT) -rm -f src/transports/utils/libnanomsg_la-backoff.lo -rm -f src/transports/utils/libnanomsg_la-base64.$(OBJEXT) -rm -f src/transports/utils/libnanomsg_la-base64.lo -rm -f src/transports/utils/libnanomsg_la-dns.$(OBJEXT) -rm -f src/transports/utils/libnanomsg_la-dns.lo -rm -f src/transports/utils/libnanomsg_la-iface.$(OBJEXT) -rm -f src/transports/utils/libnanomsg_la-iface.lo -rm -f src/transports/utils/libnanomsg_la-literal.$(OBJEXT) -rm -f src/transports/utils/libnanomsg_la-literal.lo -rm -f src/transports/utils/libnanomsg_la-port.$(OBJEXT) -rm -f src/transports/utils/libnanomsg_la-port.lo -rm -f src/transports/utils/libnanomsg_la-streamhdr.$(OBJEXT) -rm -f src/transports/utils/libnanomsg_la-streamhdr.lo -rm -f src/transports/ws/libnanomsg_la-aws.$(OBJEXT) -rm -f src/transports/ws/libnanomsg_la-aws.lo -rm -f src/transports/ws/libnanomsg_la-bws.$(OBJEXT) -rm -f src/transports/ws/libnanomsg_la-bws.lo -rm -f src/transports/ws/libnanomsg_la-cws.$(OBJEXT) -rm -f src/transports/ws/libnanomsg_la-cws.lo -rm -f src/transports/ws/libnanomsg_la-sha1.$(OBJEXT) -rm -f src/transports/ws/libnanomsg_la-sha1.lo -rm -f src/transports/ws/libnanomsg_la-sws.$(OBJEXT) -rm -f src/transports/ws/libnanomsg_la-sws.lo -rm -f src/transports/ws/libnanomsg_la-ws.$(OBJEXT) -rm -f src/transports/ws/libnanomsg_la-ws.lo -rm -f src/transports/ws/libnanomsg_la-ws_handshake.$(OBJEXT) -rm -f src/transports/ws/libnanomsg_la-ws_handshake.lo -rm -f src/utils/libnanomsg_la-alloc.$(OBJEXT) -rm -f src/utils/libnanomsg_la-alloc.lo -rm -f src/utils/libnanomsg_la-atomic.$(OBJEXT) -rm -f src/utils/libnanomsg_la-atomic.lo -rm -f src/utils/libnanomsg_la-chunk.$(OBJEXT) -rm -f src/utils/libnanomsg_la-chunk.lo -rm -f src/utils/libnanomsg_la-chunkref.$(OBJEXT) -rm -f src/utils/libnanomsg_la-chunkref.lo -rm -f src/utils/libnanomsg_la-clock.$(OBJEXT) -rm -f src/utils/libnanomsg_la-clock.lo -rm -f src/utils/libnanomsg_la-closefd.$(OBJEXT) -rm -f src/utils/libnanomsg_la-closefd.lo -rm -f src/utils/libnanomsg_la-efd.$(OBJEXT) -rm -f src/utils/libnanomsg_la-efd.lo -rm -f src/utils/libnanomsg_la-err.$(OBJEXT) -rm -f src/utils/libnanomsg_la-err.lo -rm -f src/utils/libnanomsg_la-glock.$(OBJEXT) -rm -f src/utils/libnanomsg_la-glock.lo -rm -f src/utils/libnanomsg_la-hash.$(OBJEXT) -rm -f src/utils/libnanomsg_la-hash.lo -rm -f src/utils/libnanomsg_la-list.$(OBJEXT) -rm -f src/utils/libnanomsg_la-list.lo -rm -f src/utils/libnanomsg_la-msg.$(OBJEXT) -rm -f src/utils/libnanomsg_la-msg.lo -rm -f src/utils/libnanomsg_la-mutex.$(OBJEXT) -rm -f src/utils/libnanomsg_la-mutex.lo -rm -f src/utils/libnanomsg_la-queue.$(OBJEXT) -rm -f src/utils/libnanomsg_la-queue.lo -rm -f src/utils/libnanomsg_la-random.$(OBJEXT) -rm -f src/utils/libnanomsg_la-random.lo -rm -f src/utils/libnanomsg_la-sem.$(OBJEXT) -rm -f src/utils/libnanomsg_la-sem.lo -rm -f src/utils/libnanomsg_la-sleep.$(OBJEXT) -rm -f src/utils/libnanomsg_la-sleep.lo -rm -f src/utils/libnanomsg_la-stopwatch.$(OBJEXT) -rm -f src/utils/libnanomsg_la-stopwatch.lo -rm -f src/utils/libnanomsg_la-thread.$(OBJEXT) -rm -f src/utils/libnanomsg_la-thread.lo -rm -f src/utils/libnanomsg_la-wire.$(OBJEXT) -rm -f src/utils/libnanomsg_la-wire.lo -rm -f tests/async_shutdown.$(OBJEXT) -rm -f tests/block.$(OBJEXT) -rm -f tests/bug328.$(OBJEXT) -rm -f tests/bus.$(OBJEXT) -rm -f tests/cmsg.$(OBJEXT) -rm -f tests/device.$(OBJEXT) -rm -f tests/device4.$(OBJEXT) -rm -f tests/device5.$(OBJEXT) -rm -f tests/domain.$(OBJEXT) -rm -f tests/emfile.$(OBJEXT) -rm -f tests/hash.$(OBJEXT) -rm -f tests/inproc.$(OBJEXT) -rm -f tests/inproc_shutdown.$(OBJEXT) -rm -f tests/iovec.$(OBJEXT) -rm -f tests/ipc.$(OBJEXT) -rm -f tests/ipc_shutdown.$(OBJEXT) -rm -f tests/ipc_stress.$(OBJEXT) -rm -f tests/list.$(OBJEXT) -rm -f tests/msg.$(OBJEXT) -rm -f tests/pair.$(OBJEXT) -rm -f tests/pipeline.$(OBJEXT) -rm -f tests/poll.$(OBJEXT) -rm -f tests/prio.$(OBJEXT) -rm -f tests/pubsub.$(OBJEXT) -rm -f tests/reqrep.$(OBJEXT) -rm -f tests/separation.$(OBJEXT) -rm -f tests/shutdown.$(OBJEXT) -rm -f tests/survey.$(OBJEXT) -rm -f tests/symbol.$(OBJEXT) -rm -f tests/tcp.$(OBJEXT) -rm -f tests/tcp_shutdown.$(OBJEXT) -rm -f tests/tcpmux.$(OBJEXT) -rm -f tests/term.$(OBJEXT) -rm -f tests/timeo.$(OBJEXT) -rm -f tests/trie.$(OBJEXT) -rm -f tests/ws.$(OBJEXT) -rm -f tests/zerocopy.$(OBJEXT) -rm -f tools/nanocat.$(OBJEXT) -rm -f tools/options.$(OBJEXT) -rm -f tools/tcpmuxd.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@perf/$(DEPDIR)/inproc_lat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@perf/$(DEPDIR)/inproc_thr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@perf/$(DEPDIR)/local_lat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@perf/$(DEPDIR)/local_thr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@perf/$(DEPDIR)/remote_lat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@perf/$(DEPDIR)/remote_thr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/aio/$(DEPDIR)/libnanomsg_la-ctx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/aio/$(DEPDIR)/libnanomsg_la-fsm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/aio/$(DEPDIR)/libnanomsg_la-poller.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/aio/$(DEPDIR)/libnanomsg_la-pool.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/aio/$(DEPDIR)/libnanomsg_la-timer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/aio/$(DEPDIR)/libnanomsg_la-timerset.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/aio/$(DEPDIR)/libnanomsg_la-usock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/aio/$(DEPDIR)/libnanomsg_la-worker.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/core/$(DEPDIR)/libnanomsg_la-ep.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/core/$(DEPDIR)/libnanomsg_la-epbase.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/core/$(DEPDIR)/libnanomsg_la-global.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/core/$(DEPDIR)/libnanomsg_la-pipe.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/core/$(DEPDIR)/libnanomsg_la-poll.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/core/$(DEPDIR)/libnanomsg_la-sock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/core/$(DEPDIR)/libnanomsg_la-sockbase.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/core/$(DEPDIR)/libnanomsg_la-symbol.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/devices/$(DEPDIR)/libnanomsg_la-device.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/devices/$(DEPDIR)/libnanomsg_la-tcpmuxd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/bus/$(DEPDIR)/libnanomsg_la-bus.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/bus/$(DEPDIR)/libnanomsg_la-xbus.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/pair/$(DEPDIR)/libnanomsg_la-pair.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/pair/$(DEPDIR)/libnanomsg_la-xpair.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-pull.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-push.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-xpull.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-xpush.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-pub.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-sub.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-trie.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-xpub.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-xsub.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-rep.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-req.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-task.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-xrep.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-xreq.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/survey/$(DEPDIR)/libnanomsg_la-respondent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/survey/$(DEPDIR)/libnanomsg_la-surveyor.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/survey/$(DEPDIR)/libnanomsg_la-xrespondent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/survey/$(DEPDIR)/libnanomsg_la-xsurveyor.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/utils/$(DEPDIR)/libnanomsg_la-dist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/utils/$(DEPDIR)/libnanomsg_la-excl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/utils/$(DEPDIR)/libnanomsg_la-fq.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/utils/$(DEPDIR)/libnanomsg_la-lb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/protocols/utils/$(DEPDIR)/libnanomsg_la-priolist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/inproc/$(DEPDIR)/libnanomsg_la-binproc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/inproc/$(DEPDIR)/libnanomsg_la-cinproc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/inproc/$(DEPDIR)/libnanomsg_la-inproc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/inproc/$(DEPDIR)/libnanomsg_la-ins.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/inproc/$(DEPDIR)/libnanomsg_la-msgqueue.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/inproc/$(DEPDIR)/libnanomsg_la-sinproc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/ipc/$(DEPDIR)/libnanomsg_la-aipc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/ipc/$(DEPDIR)/libnanomsg_la-bipc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/ipc/$(DEPDIR)/libnanomsg_la-cipc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/ipc/$(DEPDIR)/libnanomsg_la-ipc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/ipc/$(DEPDIR)/libnanomsg_la-sipc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/tcp/$(DEPDIR)/libnanomsg_la-atcp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/tcp/$(DEPDIR)/libnanomsg_la-btcp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/tcp/$(DEPDIR)/libnanomsg_la-ctcp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/tcp/$(DEPDIR)/libnanomsg_la-stcp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/tcp/$(DEPDIR)/libnanomsg_la-tcp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-atcpmux.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-btcpmux.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-ctcpmux.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-stcpmux.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-tcpmux.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/utils/$(DEPDIR)/libnanomsg_la-backoff.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/utils/$(DEPDIR)/libnanomsg_la-base64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/utils/$(DEPDIR)/libnanomsg_la-dns.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/utils/$(DEPDIR)/libnanomsg_la-iface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/utils/$(DEPDIR)/libnanomsg_la-literal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/utils/$(DEPDIR)/libnanomsg_la-port.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/utils/$(DEPDIR)/libnanomsg_la-streamhdr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/ws/$(DEPDIR)/libnanomsg_la-aws.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/ws/$(DEPDIR)/libnanomsg_la-bws.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/ws/$(DEPDIR)/libnanomsg_la-cws.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/ws/$(DEPDIR)/libnanomsg_la-sha1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/ws/$(DEPDIR)/libnanomsg_la-sws.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/ws/$(DEPDIR)/libnanomsg_la-ws.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/transports/ws/$(DEPDIR)/libnanomsg_la-ws_handshake.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-alloc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-atomic.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-chunk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-chunkref.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-clock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-closefd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-efd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-glock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-hash.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-list.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-msg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-mutex.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-queue.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-random.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-sem.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-sleep.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-stopwatch.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-thread.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/utils/$(DEPDIR)/libnanomsg_la-wire.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/async_shutdown.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/block.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/bug328.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/bus.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/cmsg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/device.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/device4.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/device5.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/domain.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/emfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/hash.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/inproc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/inproc_shutdown.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/iovec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/ipc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/ipc_shutdown.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/ipc_stress.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/list.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/msg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/pair.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/pipeline.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/poll.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/prio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/pubsub.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/reqrep.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/separation.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/shutdown.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/survey.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/symbol.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/tcp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/tcp_shutdown.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/tcpmux.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/term.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/timeo.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/trie.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/ws.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/zerocopy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/nanocat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/options.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/tcpmuxd.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< src/core/libnanomsg_la-ep.lo: src/core/ep.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/core/libnanomsg_la-ep.lo -MD -MP -MF src/core/$(DEPDIR)/libnanomsg_la-ep.Tpo -c -o src/core/libnanomsg_la-ep.lo `test -f 'src/core/ep.c' || echo '$(srcdir)/'`src/core/ep.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/core/$(DEPDIR)/libnanomsg_la-ep.Tpo src/core/$(DEPDIR)/libnanomsg_la-ep.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/core/ep.c' object='src/core/libnanomsg_la-ep.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/core/libnanomsg_la-ep.lo `test -f 'src/core/ep.c' || echo '$(srcdir)/'`src/core/ep.c src/core/libnanomsg_la-epbase.lo: src/core/epbase.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/core/libnanomsg_la-epbase.lo -MD -MP -MF src/core/$(DEPDIR)/libnanomsg_la-epbase.Tpo -c -o src/core/libnanomsg_la-epbase.lo `test -f 'src/core/epbase.c' || echo '$(srcdir)/'`src/core/epbase.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/core/$(DEPDIR)/libnanomsg_la-epbase.Tpo src/core/$(DEPDIR)/libnanomsg_la-epbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/core/epbase.c' object='src/core/libnanomsg_la-epbase.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/core/libnanomsg_la-epbase.lo `test -f 'src/core/epbase.c' || echo '$(srcdir)/'`src/core/epbase.c src/core/libnanomsg_la-global.lo: src/core/global.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/core/libnanomsg_la-global.lo -MD -MP -MF src/core/$(DEPDIR)/libnanomsg_la-global.Tpo -c -o src/core/libnanomsg_la-global.lo `test -f 'src/core/global.c' || echo '$(srcdir)/'`src/core/global.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/core/$(DEPDIR)/libnanomsg_la-global.Tpo src/core/$(DEPDIR)/libnanomsg_la-global.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/core/global.c' object='src/core/libnanomsg_la-global.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/core/libnanomsg_la-global.lo `test -f 'src/core/global.c' || echo '$(srcdir)/'`src/core/global.c src/core/libnanomsg_la-pipe.lo: src/core/pipe.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/core/libnanomsg_la-pipe.lo -MD -MP -MF src/core/$(DEPDIR)/libnanomsg_la-pipe.Tpo -c -o src/core/libnanomsg_la-pipe.lo `test -f 'src/core/pipe.c' || echo '$(srcdir)/'`src/core/pipe.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/core/$(DEPDIR)/libnanomsg_la-pipe.Tpo src/core/$(DEPDIR)/libnanomsg_la-pipe.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/core/pipe.c' object='src/core/libnanomsg_la-pipe.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/core/libnanomsg_la-pipe.lo `test -f 'src/core/pipe.c' || echo '$(srcdir)/'`src/core/pipe.c src/core/libnanomsg_la-poll.lo: src/core/poll.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/core/libnanomsg_la-poll.lo -MD -MP -MF src/core/$(DEPDIR)/libnanomsg_la-poll.Tpo -c -o src/core/libnanomsg_la-poll.lo `test -f 'src/core/poll.c' || echo '$(srcdir)/'`src/core/poll.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/core/$(DEPDIR)/libnanomsg_la-poll.Tpo src/core/$(DEPDIR)/libnanomsg_la-poll.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/core/poll.c' object='src/core/libnanomsg_la-poll.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/core/libnanomsg_la-poll.lo `test -f 'src/core/poll.c' || echo '$(srcdir)/'`src/core/poll.c src/core/libnanomsg_la-sock.lo: src/core/sock.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/core/libnanomsg_la-sock.lo -MD -MP -MF src/core/$(DEPDIR)/libnanomsg_la-sock.Tpo -c -o src/core/libnanomsg_la-sock.lo `test -f 'src/core/sock.c' || echo '$(srcdir)/'`src/core/sock.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/core/$(DEPDIR)/libnanomsg_la-sock.Tpo src/core/$(DEPDIR)/libnanomsg_la-sock.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/core/sock.c' object='src/core/libnanomsg_la-sock.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/core/libnanomsg_la-sock.lo `test -f 'src/core/sock.c' || echo '$(srcdir)/'`src/core/sock.c src/core/libnanomsg_la-sockbase.lo: src/core/sockbase.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/core/libnanomsg_la-sockbase.lo -MD -MP -MF src/core/$(DEPDIR)/libnanomsg_la-sockbase.Tpo -c -o src/core/libnanomsg_la-sockbase.lo `test -f 'src/core/sockbase.c' || echo '$(srcdir)/'`src/core/sockbase.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/core/$(DEPDIR)/libnanomsg_la-sockbase.Tpo src/core/$(DEPDIR)/libnanomsg_la-sockbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/core/sockbase.c' object='src/core/libnanomsg_la-sockbase.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/core/libnanomsg_la-sockbase.lo `test -f 'src/core/sockbase.c' || echo '$(srcdir)/'`src/core/sockbase.c src/core/libnanomsg_la-symbol.lo: src/core/symbol.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/core/libnanomsg_la-symbol.lo -MD -MP -MF src/core/$(DEPDIR)/libnanomsg_la-symbol.Tpo -c -o src/core/libnanomsg_la-symbol.lo `test -f 'src/core/symbol.c' || echo '$(srcdir)/'`src/core/symbol.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/core/$(DEPDIR)/libnanomsg_la-symbol.Tpo src/core/$(DEPDIR)/libnanomsg_la-symbol.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/core/symbol.c' object='src/core/libnanomsg_la-symbol.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/core/libnanomsg_la-symbol.lo `test -f 'src/core/symbol.c' || echo '$(srcdir)/'`src/core/symbol.c src/aio/libnanomsg_la-ctx.lo: src/aio/ctx.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/aio/libnanomsg_la-ctx.lo -MD -MP -MF src/aio/$(DEPDIR)/libnanomsg_la-ctx.Tpo -c -o src/aio/libnanomsg_la-ctx.lo `test -f 'src/aio/ctx.c' || echo '$(srcdir)/'`src/aio/ctx.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/aio/$(DEPDIR)/libnanomsg_la-ctx.Tpo src/aio/$(DEPDIR)/libnanomsg_la-ctx.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/aio/ctx.c' object='src/aio/libnanomsg_la-ctx.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/aio/libnanomsg_la-ctx.lo `test -f 'src/aio/ctx.c' || echo '$(srcdir)/'`src/aio/ctx.c src/aio/libnanomsg_la-fsm.lo: src/aio/fsm.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/aio/libnanomsg_la-fsm.lo -MD -MP -MF src/aio/$(DEPDIR)/libnanomsg_la-fsm.Tpo -c -o src/aio/libnanomsg_la-fsm.lo `test -f 'src/aio/fsm.c' || echo '$(srcdir)/'`src/aio/fsm.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/aio/$(DEPDIR)/libnanomsg_la-fsm.Tpo src/aio/$(DEPDIR)/libnanomsg_la-fsm.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/aio/fsm.c' object='src/aio/libnanomsg_la-fsm.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/aio/libnanomsg_la-fsm.lo `test -f 'src/aio/fsm.c' || echo '$(srcdir)/'`src/aio/fsm.c src/aio/libnanomsg_la-poller.lo: src/aio/poller.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/aio/libnanomsg_la-poller.lo -MD -MP -MF src/aio/$(DEPDIR)/libnanomsg_la-poller.Tpo -c -o src/aio/libnanomsg_la-poller.lo `test -f 'src/aio/poller.c' || echo '$(srcdir)/'`src/aio/poller.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/aio/$(DEPDIR)/libnanomsg_la-poller.Tpo src/aio/$(DEPDIR)/libnanomsg_la-poller.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/aio/poller.c' object='src/aio/libnanomsg_la-poller.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/aio/libnanomsg_la-poller.lo `test -f 'src/aio/poller.c' || echo '$(srcdir)/'`src/aio/poller.c src/aio/libnanomsg_la-pool.lo: src/aio/pool.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/aio/libnanomsg_la-pool.lo -MD -MP -MF src/aio/$(DEPDIR)/libnanomsg_la-pool.Tpo -c -o src/aio/libnanomsg_la-pool.lo `test -f 'src/aio/pool.c' || echo '$(srcdir)/'`src/aio/pool.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/aio/$(DEPDIR)/libnanomsg_la-pool.Tpo src/aio/$(DEPDIR)/libnanomsg_la-pool.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/aio/pool.c' object='src/aio/libnanomsg_la-pool.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/aio/libnanomsg_la-pool.lo `test -f 'src/aio/pool.c' || echo '$(srcdir)/'`src/aio/pool.c src/aio/libnanomsg_la-timer.lo: src/aio/timer.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/aio/libnanomsg_la-timer.lo -MD -MP -MF src/aio/$(DEPDIR)/libnanomsg_la-timer.Tpo -c -o src/aio/libnanomsg_la-timer.lo `test -f 'src/aio/timer.c' || echo '$(srcdir)/'`src/aio/timer.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/aio/$(DEPDIR)/libnanomsg_la-timer.Tpo src/aio/$(DEPDIR)/libnanomsg_la-timer.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/aio/timer.c' object='src/aio/libnanomsg_la-timer.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/aio/libnanomsg_la-timer.lo `test -f 'src/aio/timer.c' || echo '$(srcdir)/'`src/aio/timer.c src/aio/libnanomsg_la-timerset.lo: src/aio/timerset.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/aio/libnanomsg_la-timerset.lo -MD -MP -MF src/aio/$(DEPDIR)/libnanomsg_la-timerset.Tpo -c -o src/aio/libnanomsg_la-timerset.lo `test -f 'src/aio/timerset.c' || echo '$(srcdir)/'`src/aio/timerset.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/aio/$(DEPDIR)/libnanomsg_la-timerset.Tpo src/aio/$(DEPDIR)/libnanomsg_la-timerset.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/aio/timerset.c' object='src/aio/libnanomsg_la-timerset.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/aio/libnanomsg_la-timerset.lo `test -f 'src/aio/timerset.c' || echo '$(srcdir)/'`src/aio/timerset.c src/aio/libnanomsg_la-usock.lo: src/aio/usock.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/aio/libnanomsg_la-usock.lo -MD -MP -MF src/aio/$(DEPDIR)/libnanomsg_la-usock.Tpo -c -o src/aio/libnanomsg_la-usock.lo `test -f 'src/aio/usock.c' || echo '$(srcdir)/'`src/aio/usock.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/aio/$(DEPDIR)/libnanomsg_la-usock.Tpo src/aio/$(DEPDIR)/libnanomsg_la-usock.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/aio/usock.c' object='src/aio/libnanomsg_la-usock.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/aio/libnanomsg_la-usock.lo `test -f 'src/aio/usock.c' || echo '$(srcdir)/'`src/aio/usock.c src/aio/libnanomsg_la-worker.lo: src/aio/worker.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/aio/libnanomsg_la-worker.lo -MD -MP -MF src/aio/$(DEPDIR)/libnanomsg_la-worker.Tpo -c -o src/aio/libnanomsg_la-worker.lo `test -f 'src/aio/worker.c' || echo '$(srcdir)/'`src/aio/worker.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/aio/$(DEPDIR)/libnanomsg_la-worker.Tpo src/aio/$(DEPDIR)/libnanomsg_la-worker.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/aio/worker.c' object='src/aio/libnanomsg_la-worker.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/aio/libnanomsg_la-worker.lo `test -f 'src/aio/worker.c' || echo '$(srcdir)/'`src/aio/worker.c src/utils/libnanomsg_la-alloc.lo: src/utils/alloc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-alloc.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-alloc.Tpo -c -o src/utils/libnanomsg_la-alloc.lo `test -f 'src/utils/alloc.c' || echo '$(srcdir)/'`src/utils/alloc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-alloc.Tpo src/utils/$(DEPDIR)/libnanomsg_la-alloc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/alloc.c' object='src/utils/libnanomsg_la-alloc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-alloc.lo `test -f 'src/utils/alloc.c' || echo '$(srcdir)/'`src/utils/alloc.c src/utils/libnanomsg_la-atomic.lo: src/utils/atomic.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-atomic.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-atomic.Tpo -c -o src/utils/libnanomsg_la-atomic.lo `test -f 'src/utils/atomic.c' || echo '$(srcdir)/'`src/utils/atomic.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-atomic.Tpo src/utils/$(DEPDIR)/libnanomsg_la-atomic.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/atomic.c' object='src/utils/libnanomsg_la-atomic.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-atomic.lo `test -f 'src/utils/atomic.c' || echo '$(srcdir)/'`src/utils/atomic.c src/utils/libnanomsg_la-chunk.lo: src/utils/chunk.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-chunk.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-chunk.Tpo -c -o src/utils/libnanomsg_la-chunk.lo `test -f 'src/utils/chunk.c' || echo '$(srcdir)/'`src/utils/chunk.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-chunk.Tpo src/utils/$(DEPDIR)/libnanomsg_la-chunk.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/chunk.c' object='src/utils/libnanomsg_la-chunk.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-chunk.lo `test -f 'src/utils/chunk.c' || echo '$(srcdir)/'`src/utils/chunk.c src/utils/libnanomsg_la-chunkref.lo: src/utils/chunkref.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-chunkref.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-chunkref.Tpo -c -o src/utils/libnanomsg_la-chunkref.lo `test -f 'src/utils/chunkref.c' || echo '$(srcdir)/'`src/utils/chunkref.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-chunkref.Tpo src/utils/$(DEPDIR)/libnanomsg_la-chunkref.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/chunkref.c' object='src/utils/libnanomsg_la-chunkref.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-chunkref.lo `test -f 'src/utils/chunkref.c' || echo '$(srcdir)/'`src/utils/chunkref.c src/utils/libnanomsg_la-clock.lo: src/utils/clock.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-clock.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-clock.Tpo -c -o src/utils/libnanomsg_la-clock.lo `test -f 'src/utils/clock.c' || echo '$(srcdir)/'`src/utils/clock.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-clock.Tpo src/utils/$(DEPDIR)/libnanomsg_la-clock.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/clock.c' object='src/utils/libnanomsg_la-clock.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-clock.lo `test -f 'src/utils/clock.c' || echo '$(srcdir)/'`src/utils/clock.c src/utils/libnanomsg_la-closefd.lo: src/utils/closefd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-closefd.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-closefd.Tpo -c -o src/utils/libnanomsg_la-closefd.lo `test -f 'src/utils/closefd.c' || echo '$(srcdir)/'`src/utils/closefd.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-closefd.Tpo src/utils/$(DEPDIR)/libnanomsg_la-closefd.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/closefd.c' object='src/utils/libnanomsg_la-closefd.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-closefd.lo `test -f 'src/utils/closefd.c' || echo '$(srcdir)/'`src/utils/closefd.c src/utils/libnanomsg_la-efd.lo: src/utils/efd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-efd.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-efd.Tpo -c -o src/utils/libnanomsg_la-efd.lo `test -f 'src/utils/efd.c' || echo '$(srcdir)/'`src/utils/efd.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-efd.Tpo src/utils/$(DEPDIR)/libnanomsg_la-efd.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/efd.c' object='src/utils/libnanomsg_la-efd.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-efd.lo `test -f 'src/utils/efd.c' || echo '$(srcdir)/'`src/utils/efd.c src/utils/libnanomsg_la-err.lo: src/utils/err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-err.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-err.Tpo -c -o src/utils/libnanomsg_la-err.lo `test -f 'src/utils/err.c' || echo '$(srcdir)/'`src/utils/err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-err.Tpo src/utils/$(DEPDIR)/libnanomsg_la-err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/err.c' object='src/utils/libnanomsg_la-err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-err.lo `test -f 'src/utils/err.c' || echo '$(srcdir)/'`src/utils/err.c src/utils/libnanomsg_la-glock.lo: src/utils/glock.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-glock.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-glock.Tpo -c -o src/utils/libnanomsg_la-glock.lo `test -f 'src/utils/glock.c' || echo '$(srcdir)/'`src/utils/glock.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-glock.Tpo src/utils/$(DEPDIR)/libnanomsg_la-glock.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/glock.c' object='src/utils/libnanomsg_la-glock.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-glock.lo `test -f 'src/utils/glock.c' || echo '$(srcdir)/'`src/utils/glock.c src/utils/libnanomsg_la-hash.lo: src/utils/hash.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-hash.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-hash.Tpo -c -o src/utils/libnanomsg_la-hash.lo `test -f 'src/utils/hash.c' || echo '$(srcdir)/'`src/utils/hash.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-hash.Tpo src/utils/$(DEPDIR)/libnanomsg_la-hash.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/hash.c' object='src/utils/libnanomsg_la-hash.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-hash.lo `test -f 'src/utils/hash.c' || echo '$(srcdir)/'`src/utils/hash.c src/utils/libnanomsg_la-list.lo: src/utils/list.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-list.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-list.Tpo -c -o src/utils/libnanomsg_la-list.lo `test -f 'src/utils/list.c' || echo '$(srcdir)/'`src/utils/list.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-list.Tpo src/utils/$(DEPDIR)/libnanomsg_la-list.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/list.c' object='src/utils/libnanomsg_la-list.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-list.lo `test -f 'src/utils/list.c' || echo '$(srcdir)/'`src/utils/list.c src/utils/libnanomsg_la-msg.lo: src/utils/msg.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-msg.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-msg.Tpo -c -o src/utils/libnanomsg_la-msg.lo `test -f 'src/utils/msg.c' || echo '$(srcdir)/'`src/utils/msg.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-msg.Tpo src/utils/$(DEPDIR)/libnanomsg_la-msg.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/msg.c' object='src/utils/libnanomsg_la-msg.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-msg.lo `test -f 'src/utils/msg.c' || echo '$(srcdir)/'`src/utils/msg.c src/utils/libnanomsg_la-mutex.lo: src/utils/mutex.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-mutex.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-mutex.Tpo -c -o src/utils/libnanomsg_la-mutex.lo `test -f 'src/utils/mutex.c' || echo '$(srcdir)/'`src/utils/mutex.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-mutex.Tpo src/utils/$(DEPDIR)/libnanomsg_la-mutex.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/mutex.c' object='src/utils/libnanomsg_la-mutex.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-mutex.lo `test -f 'src/utils/mutex.c' || echo '$(srcdir)/'`src/utils/mutex.c src/utils/libnanomsg_la-queue.lo: src/utils/queue.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-queue.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-queue.Tpo -c -o src/utils/libnanomsg_la-queue.lo `test -f 'src/utils/queue.c' || echo '$(srcdir)/'`src/utils/queue.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-queue.Tpo src/utils/$(DEPDIR)/libnanomsg_la-queue.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/queue.c' object='src/utils/libnanomsg_la-queue.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-queue.lo `test -f 'src/utils/queue.c' || echo '$(srcdir)/'`src/utils/queue.c src/utils/libnanomsg_la-random.lo: src/utils/random.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-random.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-random.Tpo -c -o src/utils/libnanomsg_la-random.lo `test -f 'src/utils/random.c' || echo '$(srcdir)/'`src/utils/random.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-random.Tpo src/utils/$(DEPDIR)/libnanomsg_la-random.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/random.c' object='src/utils/libnanomsg_la-random.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-random.lo `test -f 'src/utils/random.c' || echo '$(srcdir)/'`src/utils/random.c src/utils/libnanomsg_la-sem.lo: src/utils/sem.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-sem.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-sem.Tpo -c -o src/utils/libnanomsg_la-sem.lo `test -f 'src/utils/sem.c' || echo '$(srcdir)/'`src/utils/sem.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-sem.Tpo src/utils/$(DEPDIR)/libnanomsg_la-sem.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/sem.c' object='src/utils/libnanomsg_la-sem.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-sem.lo `test -f 'src/utils/sem.c' || echo '$(srcdir)/'`src/utils/sem.c src/utils/libnanomsg_la-sleep.lo: src/utils/sleep.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-sleep.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-sleep.Tpo -c -o src/utils/libnanomsg_la-sleep.lo `test -f 'src/utils/sleep.c' || echo '$(srcdir)/'`src/utils/sleep.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-sleep.Tpo src/utils/$(DEPDIR)/libnanomsg_la-sleep.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/sleep.c' object='src/utils/libnanomsg_la-sleep.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-sleep.lo `test -f 'src/utils/sleep.c' || echo '$(srcdir)/'`src/utils/sleep.c src/utils/libnanomsg_la-stopwatch.lo: src/utils/stopwatch.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-stopwatch.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-stopwatch.Tpo -c -o src/utils/libnanomsg_la-stopwatch.lo `test -f 'src/utils/stopwatch.c' || echo '$(srcdir)/'`src/utils/stopwatch.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-stopwatch.Tpo src/utils/$(DEPDIR)/libnanomsg_la-stopwatch.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/stopwatch.c' object='src/utils/libnanomsg_la-stopwatch.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-stopwatch.lo `test -f 'src/utils/stopwatch.c' || echo '$(srcdir)/'`src/utils/stopwatch.c src/utils/libnanomsg_la-thread.lo: src/utils/thread.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-thread.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-thread.Tpo -c -o src/utils/libnanomsg_la-thread.lo `test -f 'src/utils/thread.c' || echo '$(srcdir)/'`src/utils/thread.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-thread.Tpo src/utils/$(DEPDIR)/libnanomsg_la-thread.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/thread.c' object='src/utils/libnanomsg_la-thread.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-thread.lo `test -f 'src/utils/thread.c' || echo '$(srcdir)/'`src/utils/thread.c src/utils/libnanomsg_la-wire.lo: src/utils/wire.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/utils/libnanomsg_la-wire.lo -MD -MP -MF src/utils/$(DEPDIR)/libnanomsg_la-wire.Tpo -c -o src/utils/libnanomsg_la-wire.lo `test -f 'src/utils/wire.c' || echo '$(srcdir)/'`src/utils/wire.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/utils/$(DEPDIR)/libnanomsg_la-wire.Tpo src/utils/$(DEPDIR)/libnanomsg_la-wire.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/utils/wire.c' object='src/utils/libnanomsg_la-wire.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/utils/libnanomsg_la-wire.lo `test -f 'src/utils/wire.c' || echo '$(srcdir)/'`src/utils/wire.c src/protocols/bus/libnanomsg_la-bus.lo: src/protocols/bus/bus.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/bus/libnanomsg_la-bus.lo -MD -MP -MF src/protocols/bus/$(DEPDIR)/libnanomsg_la-bus.Tpo -c -o src/protocols/bus/libnanomsg_la-bus.lo `test -f 'src/protocols/bus/bus.c' || echo '$(srcdir)/'`src/protocols/bus/bus.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/bus/$(DEPDIR)/libnanomsg_la-bus.Tpo src/protocols/bus/$(DEPDIR)/libnanomsg_la-bus.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/bus/bus.c' object='src/protocols/bus/libnanomsg_la-bus.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/bus/libnanomsg_la-bus.lo `test -f 'src/protocols/bus/bus.c' || echo '$(srcdir)/'`src/protocols/bus/bus.c src/protocols/bus/libnanomsg_la-xbus.lo: src/protocols/bus/xbus.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/bus/libnanomsg_la-xbus.lo -MD -MP -MF src/protocols/bus/$(DEPDIR)/libnanomsg_la-xbus.Tpo -c -o src/protocols/bus/libnanomsg_la-xbus.lo `test -f 'src/protocols/bus/xbus.c' || echo '$(srcdir)/'`src/protocols/bus/xbus.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/bus/$(DEPDIR)/libnanomsg_la-xbus.Tpo src/protocols/bus/$(DEPDIR)/libnanomsg_la-xbus.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/bus/xbus.c' object='src/protocols/bus/libnanomsg_la-xbus.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/bus/libnanomsg_la-xbus.lo `test -f 'src/protocols/bus/xbus.c' || echo '$(srcdir)/'`src/protocols/bus/xbus.c src/protocols/pipeline/libnanomsg_la-push.lo: src/protocols/pipeline/push.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/pipeline/libnanomsg_la-push.lo -MD -MP -MF src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-push.Tpo -c -o src/protocols/pipeline/libnanomsg_la-push.lo `test -f 'src/protocols/pipeline/push.c' || echo '$(srcdir)/'`src/protocols/pipeline/push.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-push.Tpo src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-push.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/pipeline/push.c' object='src/protocols/pipeline/libnanomsg_la-push.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/pipeline/libnanomsg_la-push.lo `test -f 'src/protocols/pipeline/push.c' || echo '$(srcdir)/'`src/protocols/pipeline/push.c src/protocols/pipeline/libnanomsg_la-pull.lo: src/protocols/pipeline/pull.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/pipeline/libnanomsg_la-pull.lo -MD -MP -MF src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-pull.Tpo -c -o src/protocols/pipeline/libnanomsg_la-pull.lo `test -f 'src/protocols/pipeline/pull.c' || echo '$(srcdir)/'`src/protocols/pipeline/pull.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-pull.Tpo src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-pull.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/pipeline/pull.c' object='src/protocols/pipeline/libnanomsg_la-pull.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/pipeline/libnanomsg_la-pull.lo `test -f 'src/protocols/pipeline/pull.c' || echo '$(srcdir)/'`src/protocols/pipeline/pull.c src/protocols/pipeline/libnanomsg_la-xpull.lo: src/protocols/pipeline/xpull.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/pipeline/libnanomsg_la-xpull.lo -MD -MP -MF src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-xpull.Tpo -c -o src/protocols/pipeline/libnanomsg_la-xpull.lo `test -f 'src/protocols/pipeline/xpull.c' || echo '$(srcdir)/'`src/protocols/pipeline/xpull.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-xpull.Tpo src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-xpull.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/pipeline/xpull.c' object='src/protocols/pipeline/libnanomsg_la-xpull.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/pipeline/libnanomsg_la-xpull.lo `test -f 'src/protocols/pipeline/xpull.c' || echo '$(srcdir)/'`src/protocols/pipeline/xpull.c src/protocols/pipeline/libnanomsg_la-xpush.lo: src/protocols/pipeline/xpush.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/pipeline/libnanomsg_la-xpush.lo -MD -MP -MF src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-xpush.Tpo -c -o src/protocols/pipeline/libnanomsg_la-xpush.lo `test -f 'src/protocols/pipeline/xpush.c' || echo '$(srcdir)/'`src/protocols/pipeline/xpush.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-xpush.Tpo src/protocols/pipeline/$(DEPDIR)/libnanomsg_la-xpush.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/pipeline/xpush.c' object='src/protocols/pipeline/libnanomsg_la-xpush.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/pipeline/libnanomsg_la-xpush.lo `test -f 'src/protocols/pipeline/xpush.c' || echo '$(srcdir)/'`src/protocols/pipeline/xpush.c src/protocols/pair/libnanomsg_la-pair.lo: src/protocols/pair/pair.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/pair/libnanomsg_la-pair.lo -MD -MP -MF src/protocols/pair/$(DEPDIR)/libnanomsg_la-pair.Tpo -c -o src/protocols/pair/libnanomsg_la-pair.lo `test -f 'src/protocols/pair/pair.c' || echo '$(srcdir)/'`src/protocols/pair/pair.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/pair/$(DEPDIR)/libnanomsg_la-pair.Tpo src/protocols/pair/$(DEPDIR)/libnanomsg_la-pair.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/pair/pair.c' object='src/protocols/pair/libnanomsg_la-pair.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/pair/libnanomsg_la-pair.lo `test -f 'src/protocols/pair/pair.c' || echo '$(srcdir)/'`src/protocols/pair/pair.c src/protocols/pair/libnanomsg_la-xpair.lo: src/protocols/pair/xpair.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/pair/libnanomsg_la-xpair.lo -MD -MP -MF src/protocols/pair/$(DEPDIR)/libnanomsg_la-xpair.Tpo -c -o src/protocols/pair/libnanomsg_la-xpair.lo `test -f 'src/protocols/pair/xpair.c' || echo '$(srcdir)/'`src/protocols/pair/xpair.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/pair/$(DEPDIR)/libnanomsg_la-xpair.Tpo src/protocols/pair/$(DEPDIR)/libnanomsg_la-xpair.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/pair/xpair.c' object='src/protocols/pair/libnanomsg_la-xpair.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/pair/libnanomsg_la-xpair.lo `test -f 'src/protocols/pair/xpair.c' || echo '$(srcdir)/'`src/protocols/pair/xpair.c src/protocols/pubsub/libnanomsg_la-pub.lo: src/protocols/pubsub/pub.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/pubsub/libnanomsg_la-pub.lo -MD -MP -MF src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-pub.Tpo -c -o src/protocols/pubsub/libnanomsg_la-pub.lo `test -f 'src/protocols/pubsub/pub.c' || echo '$(srcdir)/'`src/protocols/pubsub/pub.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-pub.Tpo src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-pub.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/pubsub/pub.c' object='src/protocols/pubsub/libnanomsg_la-pub.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/pubsub/libnanomsg_la-pub.lo `test -f 'src/protocols/pubsub/pub.c' || echo '$(srcdir)/'`src/protocols/pubsub/pub.c src/protocols/pubsub/libnanomsg_la-sub.lo: src/protocols/pubsub/sub.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/pubsub/libnanomsg_la-sub.lo -MD -MP -MF src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-sub.Tpo -c -o src/protocols/pubsub/libnanomsg_la-sub.lo `test -f 'src/protocols/pubsub/sub.c' || echo '$(srcdir)/'`src/protocols/pubsub/sub.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-sub.Tpo src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-sub.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/pubsub/sub.c' object='src/protocols/pubsub/libnanomsg_la-sub.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/pubsub/libnanomsg_la-sub.lo `test -f 'src/protocols/pubsub/sub.c' || echo '$(srcdir)/'`src/protocols/pubsub/sub.c src/protocols/pubsub/libnanomsg_la-trie.lo: src/protocols/pubsub/trie.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/pubsub/libnanomsg_la-trie.lo -MD -MP -MF src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-trie.Tpo -c -o src/protocols/pubsub/libnanomsg_la-trie.lo `test -f 'src/protocols/pubsub/trie.c' || echo '$(srcdir)/'`src/protocols/pubsub/trie.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-trie.Tpo src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-trie.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/pubsub/trie.c' object='src/protocols/pubsub/libnanomsg_la-trie.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/pubsub/libnanomsg_la-trie.lo `test -f 'src/protocols/pubsub/trie.c' || echo '$(srcdir)/'`src/protocols/pubsub/trie.c src/protocols/pubsub/libnanomsg_la-xpub.lo: src/protocols/pubsub/xpub.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/pubsub/libnanomsg_la-xpub.lo -MD -MP -MF src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-xpub.Tpo -c -o src/protocols/pubsub/libnanomsg_la-xpub.lo `test -f 'src/protocols/pubsub/xpub.c' || echo '$(srcdir)/'`src/protocols/pubsub/xpub.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-xpub.Tpo src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-xpub.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/pubsub/xpub.c' object='src/protocols/pubsub/libnanomsg_la-xpub.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/pubsub/libnanomsg_la-xpub.lo `test -f 'src/protocols/pubsub/xpub.c' || echo '$(srcdir)/'`src/protocols/pubsub/xpub.c src/protocols/pubsub/libnanomsg_la-xsub.lo: src/protocols/pubsub/xsub.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/pubsub/libnanomsg_la-xsub.lo -MD -MP -MF src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-xsub.Tpo -c -o src/protocols/pubsub/libnanomsg_la-xsub.lo `test -f 'src/protocols/pubsub/xsub.c' || echo '$(srcdir)/'`src/protocols/pubsub/xsub.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-xsub.Tpo src/protocols/pubsub/$(DEPDIR)/libnanomsg_la-xsub.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/pubsub/xsub.c' object='src/protocols/pubsub/libnanomsg_la-xsub.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/pubsub/libnanomsg_la-xsub.lo `test -f 'src/protocols/pubsub/xsub.c' || echo '$(srcdir)/'`src/protocols/pubsub/xsub.c src/protocols/reqrep/libnanomsg_la-req.lo: src/protocols/reqrep/req.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/reqrep/libnanomsg_la-req.lo -MD -MP -MF src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-req.Tpo -c -o src/protocols/reqrep/libnanomsg_la-req.lo `test -f 'src/protocols/reqrep/req.c' || echo '$(srcdir)/'`src/protocols/reqrep/req.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-req.Tpo src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-req.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/reqrep/req.c' object='src/protocols/reqrep/libnanomsg_la-req.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/reqrep/libnanomsg_la-req.lo `test -f 'src/protocols/reqrep/req.c' || echo '$(srcdir)/'`src/protocols/reqrep/req.c src/protocols/reqrep/libnanomsg_la-rep.lo: src/protocols/reqrep/rep.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/reqrep/libnanomsg_la-rep.lo -MD -MP -MF src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-rep.Tpo -c -o src/protocols/reqrep/libnanomsg_la-rep.lo `test -f 'src/protocols/reqrep/rep.c' || echo '$(srcdir)/'`src/protocols/reqrep/rep.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-rep.Tpo src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-rep.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/reqrep/rep.c' object='src/protocols/reqrep/libnanomsg_la-rep.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/reqrep/libnanomsg_la-rep.lo `test -f 'src/protocols/reqrep/rep.c' || echo '$(srcdir)/'`src/protocols/reqrep/rep.c src/protocols/reqrep/libnanomsg_la-task.lo: src/protocols/reqrep/task.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/reqrep/libnanomsg_la-task.lo -MD -MP -MF src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-task.Tpo -c -o src/protocols/reqrep/libnanomsg_la-task.lo `test -f 'src/protocols/reqrep/task.c' || echo '$(srcdir)/'`src/protocols/reqrep/task.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-task.Tpo src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-task.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/reqrep/task.c' object='src/protocols/reqrep/libnanomsg_la-task.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/reqrep/libnanomsg_la-task.lo `test -f 'src/protocols/reqrep/task.c' || echo '$(srcdir)/'`src/protocols/reqrep/task.c src/protocols/reqrep/libnanomsg_la-xrep.lo: src/protocols/reqrep/xrep.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/reqrep/libnanomsg_la-xrep.lo -MD -MP -MF src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-xrep.Tpo -c -o src/protocols/reqrep/libnanomsg_la-xrep.lo `test -f 'src/protocols/reqrep/xrep.c' || echo '$(srcdir)/'`src/protocols/reqrep/xrep.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-xrep.Tpo src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-xrep.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/reqrep/xrep.c' object='src/protocols/reqrep/libnanomsg_la-xrep.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/reqrep/libnanomsg_la-xrep.lo `test -f 'src/protocols/reqrep/xrep.c' || echo '$(srcdir)/'`src/protocols/reqrep/xrep.c src/protocols/reqrep/libnanomsg_la-xreq.lo: src/protocols/reqrep/xreq.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/reqrep/libnanomsg_la-xreq.lo -MD -MP -MF src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-xreq.Tpo -c -o src/protocols/reqrep/libnanomsg_la-xreq.lo `test -f 'src/protocols/reqrep/xreq.c' || echo '$(srcdir)/'`src/protocols/reqrep/xreq.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-xreq.Tpo src/protocols/reqrep/$(DEPDIR)/libnanomsg_la-xreq.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/reqrep/xreq.c' object='src/protocols/reqrep/libnanomsg_la-xreq.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/reqrep/libnanomsg_la-xreq.lo `test -f 'src/protocols/reqrep/xreq.c' || echo '$(srcdir)/'`src/protocols/reqrep/xreq.c src/protocols/survey/libnanomsg_la-respondent.lo: src/protocols/survey/respondent.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/survey/libnanomsg_la-respondent.lo -MD -MP -MF src/protocols/survey/$(DEPDIR)/libnanomsg_la-respondent.Tpo -c -o src/protocols/survey/libnanomsg_la-respondent.lo `test -f 'src/protocols/survey/respondent.c' || echo '$(srcdir)/'`src/protocols/survey/respondent.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/survey/$(DEPDIR)/libnanomsg_la-respondent.Tpo src/protocols/survey/$(DEPDIR)/libnanomsg_la-respondent.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/survey/respondent.c' object='src/protocols/survey/libnanomsg_la-respondent.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/survey/libnanomsg_la-respondent.lo `test -f 'src/protocols/survey/respondent.c' || echo '$(srcdir)/'`src/protocols/survey/respondent.c src/protocols/survey/libnanomsg_la-surveyor.lo: src/protocols/survey/surveyor.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/survey/libnanomsg_la-surveyor.lo -MD -MP -MF src/protocols/survey/$(DEPDIR)/libnanomsg_la-surveyor.Tpo -c -o src/protocols/survey/libnanomsg_la-surveyor.lo `test -f 'src/protocols/survey/surveyor.c' || echo '$(srcdir)/'`src/protocols/survey/surveyor.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/survey/$(DEPDIR)/libnanomsg_la-surveyor.Tpo src/protocols/survey/$(DEPDIR)/libnanomsg_la-surveyor.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/survey/surveyor.c' object='src/protocols/survey/libnanomsg_la-surveyor.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/survey/libnanomsg_la-surveyor.lo `test -f 'src/protocols/survey/surveyor.c' || echo '$(srcdir)/'`src/protocols/survey/surveyor.c src/protocols/survey/libnanomsg_la-xrespondent.lo: src/protocols/survey/xrespondent.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/survey/libnanomsg_la-xrespondent.lo -MD -MP -MF src/protocols/survey/$(DEPDIR)/libnanomsg_la-xrespondent.Tpo -c -o src/protocols/survey/libnanomsg_la-xrespondent.lo `test -f 'src/protocols/survey/xrespondent.c' || echo '$(srcdir)/'`src/protocols/survey/xrespondent.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/survey/$(DEPDIR)/libnanomsg_la-xrespondent.Tpo src/protocols/survey/$(DEPDIR)/libnanomsg_la-xrespondent.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/survey/xrespondent.c' object='src/protocols/survey/libnanomsg_la-xrespondent.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/survey/libnanomsg_la-xrespondent.lo `test -f 'src/protocols/survey/xrespondent.c' || echo '$(srcdir)/'`src/protocols/survey/xrespondent.c src/protocols/survey/libnanomsg_la-xsurveyor.lo: src/protocols/survey/xsurveyor.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/survey/libnanomsg_la-xsurveyor.lo -MD -MP -MF src/protocols/survey/$(DEPDIR)/libnanomsg_la-xsurveyor.Tpo -c -o src/protocols/survey/libnanomsg_la-xsurveyor.lo `test -f 'src/protocols/survey/xsurveyor.c' || echo '$(srcdir)/'`src/protocols/survey/xsurveyor.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/survey/$(DEPDIR)/libnanomsg_la-xsurveyor.Tpo src/protocols/survey/$(DEPDIR)/libnanomsg_la-xsurveyor.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/survey/xsurveyor.c' object='src/protocols/survey/libnanomsg_la-xsurveyor.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/survey/libnanomsg_la-xsurveyor.lo `test -f 'src/protocols/survey/xsurveyor.c' || echo '$(srcdir)/'`src/protocols/survey/xsurveyor.c src/protocols/utils/libnanomsg_la-dist.lo: src/protocols/utils/dist.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/utils/libnanomsg_la-dist.lo -MD -MP -MF src/protocols/utils/$(DEPDIR)/libnanomsg_la-dist.Tpo -c -o src/protocols/utils/libnanomsg_la-dist.lo `test -f 'src/protocols/utils/dist.c' || echo '$(srcdir)/'`src/protocols/utils/dist.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/utils/$(DEPDIR)/libnanomsg_la-dist.Tpo src/protocols/utils/$(DEPDIR)/libnanomsg_la-dist.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/utils/dist.c' object='src/protocols/utils/libnanomsg_la-dist.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/utils/libnanomsg_la-dist.lo `test -f 'src/protocols/utils/dist.c' || echo '$(srcdir)/'`src/protocols/utils/dist.c src/protocols/utils/libnanomsg_la-excl.lo: src/protocols/utils/excl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/utils/libnanomsg_la-excl.lo -MD -MP -MF src/protocols/utils/$(DEPDIR)/libnanomsg_la-excl.Tpo -c -o src/protocols/utils/libnanomsg_la-excl.lo `test -f 'src/protocols/utils/excl.c' || echo '$(srcdir)/'`src/protocols/utils/excl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/utils/$(DEPDIR)/libnanomsg_la-excl.Tpo src/protocols/utils/$(DEPDIR)/libnanomsg_la-excl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/utils/excl.c' object='src/protocols/utils/libnanomsg_la-excl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/utils/libnanomsg_la-excl.lo `test -f 'src/protocols/utils/excl.c' || echo '$(srcdir)/'`src/protocols/utils/excl.c src/protocols/utils/libnanomsg_la-fq.lo: src/protocols/utils/fq.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/utils/libnanomsg_la-fq.lo -MD -MP -MF src/protocols/utils/$(DEPDIR)/libnanomsg_la-fq.Tpo -c -o src/protocols/utils/libnanomsg_la-fq.lo `test -f 'src/protocols/utils/fq.c' || echo '$(srcdir)/'`src/protocols/utils/fq.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/utils/$(DEPDIR)/libnanomsg_la-fq.Tpo src/protocols/utils/$(DEPDIR)/libnanomsg_la-fq.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/utils/fq.c' object='src/protocols/utils/libnanomsg_la-fq.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/utils/libnanomsg_la-fq.lo `test -f 'src/protocols/utils/fq.c' || echo '$(srcdir)/'`src/protocols/utils/fq.c src/protocols/utils/libnanomsg_la-lb.lo: src/protocols/utils/lb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/utils/libnanomsg_la-lb.lo -MD -MP -MF src/protocols/utils/$(DEPDIR)/libnanomsg_la-lb.Tpo -c -o src/protocols/utils/libnanomsg_la-lb.lo `test -f 'src/protocols/utils/lb.c' || echo '$(srcdir)/'`src/protocols/utils/lb.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/utils/$(DEPDIR)/libnanomsg_la-lb.Tpo src/protocols/utils/$(DEPDIR)/libnanomsg_la-lb.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/utils/lb.c' object='src/protocols/utils/libnanomsg_la-lb.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/utils/libnanomsg_la-lb.lo `test -f 'src/protocols/utils/lb.c' || echo '$(srcdir)/'`src/protocols/utils/lb.c src/protocols/utils/libnanomsg_la-priolist.lo: src/protocols/utils/priolist.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/protocols/utils/libnanomsg_la-priolist.lo -MD -MP -MF src/protocols/utils/$(DEPDIR)/libnanomsg_la-priolist.Tpo -c -o src/protocols/utils/libnanomsg_la-priolist.lo `test -f 'src/protocols/utils/priolist.c' || echo '$(srcdir)/'`src/protocols/utils/priolist.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/protocols/utils/$(DEPDIR)/libnanomsg_la-priolist.Tpo src/protocols/utils/$(DEPDIR)/libnanomsg_la-priolist.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/protocols/utils/priolist.c' object='src/protocols/utils/libnanomsg_la-priolist.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/protocols/utils/libnanomsg_la-priolist.lo `test -f 'src/protocols/utils/priolist.c' || echo '$(srcdir)/'`src/protocols/utils/priolist.c src/transports/utils/libnanomsg_la-backoff.lo: src/transports/utils/backoff.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/utils/libnanomsg_la-backoff.lo -MD -MP -MF src/transports/utils/$(DEPDIR)/libnanomsg_la-backoff.Tpo -c -o src/transports/utils/libnanomsg_la-backoff.lo `test -f 'src/transports/utils/backoff.c' || echo '$(srcdir)/'`src/transports/utils/backoff.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/utils/$(DEPDIR)/libnanomsg_la-backoff.Tpo src/transports/utils/$(DEPDIR)/libnanomsg_la-backoff.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/utils/backoff.c' object='src/transports/utils/libnanomsg_la-backoff.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/utils/libnanomsg_la-backoff.lo `test -f 'src/transports/utils/backoff.c' || echo '$(srcdir)/'`src/transports/utils/backoff.c src/transports/utils/libnanomsg_la-dns.lo: src/transports/utils/dns.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/utils/libnanomsg_la-dns.lo -MD -MP -MF src/transports/utils/$(DEPDIR)/libnanomsg_la-dns.Tpo -c -o src/transports/utils/libnanomsg_la-dns.lo `test -f 'src/transports/utils/dns.c' || echo '$(srcdir)/'`src/transports/utils/dns.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/utils/$(DEPDIR)/libnanomsg_la-dns.Tpo src/transports/utils/$(DEPDIR)/libnanomsg_la-dns.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/utils/dns.c' object='src/transports/utils/libnanomsg_la-dns.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/utils/libnanomsg_la-dns.lo `test -f 'src/transports/utils/dns.c' || echo '$(srcdir)/'`src/transports/utils/dns.c src/transports/utils/libnanomsg_la-iface.lo: src/transports/utils/iface.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/utils/libnanomsg_la-iface.lo -MD -MP -MF src/transports/utils/$(DEPDIR)/libnanomsg_la-iface.Tpo -c -o src/transports/utils/libnanomsg_la-iface.lo `test -f 'src/transports/utils/iface.c' || echo '$(srcdir)/'`src/transports/utils/iface.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/utils/$(DEPDIR)/libnanomsg_la-iface.Tpo src/transports/utils/$(DEPDIR)/libnanomsg_la-iface.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/utils/iface.c' object='src/transports/utils/libnanomsg_la-iface.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/utils/libnanomsg_la-iface.lo `test -f 'src/transports/utils/iface.c' || echo '$(srcdir)/'`src/transports/utils/iface.c src/transports/utils/libnanomsg_la-literal.lo: src/transports/utils/literal.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/utils/libnanomsg_la-literal.lo -MD -MP -MF src/transports/utils/$(DEPDIR)/libnanomsg_la-literal.Tpo -c -o src/transports/utils/libnanomsg_la-literal.lo `test -f 'src/transports/utils/literal.c' || echo '$(srcdir)/'`src/transports/utils/literal.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/utils/$(DEPDIR)/libnanomsg_la-literal.Tpo src/transports/utils/$(DEPDIR)/libnanomsg_la-literal.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/utils/literal.c' object='src/transports/utils/libnanomsg_la-literal.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/utils/libnanomsg_la-literal.lo `test -f 'src/transports/utils/literal.c' || echo '$(srcdir)/'`src/transports/utils/literal.c src/transports/utils/libnanomsg_la-port.lo: src/transports/utils/port.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/utils/libnanomsg_la-port.lo -MD -MP -MF src/transports/utils/$(DEPDIR)/libnanomsg_la-port.Tpo -c -o src/transports/utils/libnanomsg_la-port.lo `test -f 'src/transports/utils/port.c' || echo '$(srcdir)/'`src/transports/utils/port.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/utils/$(DEPDIR)/libnanomsg_la-port.Tpo src/transports/utils/$(DEPDIR)/libnanomsg_la-port.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/utils/port.c' object='src/transports/utils/libnanomsg_la-port.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/utils/libnanomsg_la-port.lo `test -f 'src/transports/utils/port.c' || echo '$(srcdir)/'`src/transports/utils/port.c src/transports/utils/libnanomsg_la-streamhdr.lo: src/transports/utils/streamhdr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/utils/libnanomsg_la-streamhdr.lo -MD -MP -MF src/transports/utils/$(DEPDIR)/libnanomsg_la-streamhdr.Tpo -c -o src/transports/utils/libnanomsg_la-streamhdr.lo `test -f 'src/transports/utils/streamhdr.c' || echo '$(srcdir)/'`src/transports/utils/streamhdr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/utils/$(DEPDIR)/libnanomsg_la-streamhdr.Tpo src/transports/utils/$(DEPDIR)/libnanomsg_la-streamhdr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/utils/streamhdr.c' object='src/transports/utils/libnanomsg_la-streamhdr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/utils/libnanomsg_la-streamhdr.lo `test -f 'src/transports/utils/streamhdr.c' || echo '$(srcdir)/'`src/transports/utils/streamhdr.c src/transports/utils/libnanomsg_la-base64.lo: src/transports/utils/base64.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/utils/libnanomsg_la-base64.lo -MD -MP -MF src/transports/utils/$(DEPDIR)/libnanomsg_la-base64.Tpo -c -o src/transports/utils/libnanomsg_la-base64.lo `test -f 'src/transports/utils/base64.c' || echo '$(srcdir)/'`src/transports/utils/base64.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/utils/$(DEPDIR)/libnanomsg_la-base64.Tpo src/transports/utils/$(DEPDIR)/libnanomsg_la-base64.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/utils/base64.c' object='src/transports/utils/libnanomsg_la-base64.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/utils/libnanomsg_la-base64.lo `test -f 'src/transports/utils/base64.c' || echo '$(srcdir)/'`src/transports/utils/base64.c src/transports/inproc/libnanomsg_la-binproc.lo: src/transports/inproc/binproc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/inproc/libnanomsg_la-binproc.lo -MD -MP -MF src/transports/inproc/$(DEPDIR)/libnanomsg_la-binproc.Tpo -c -o src/transports/inproc/libnanomsg_la-binproc.lo `test -f 'src/transports/inproc/binproc.c' || echo '$(srcdir)/'`src/transports/inproc/binproc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/inproc/$(DEPDIR)/libnanomsg_la-binproc.Tpo src/transports/inproc/$(DEPDIR)/libnanomsg_la-binproc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/inproc/binproc.c' object='src/transports/inproc/libnanomsg_la-binproc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/inproc/libnanomsg_la-binproc.lo `test -f 'src/transports/inproc/binproc.c' || echo '$(srcdir)/'`src/transports/inproc/binproc.c src/transports/inproc/libnanomsg_la-cinproc.lo: src/transports/inproc/cinproc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/inproc/libnanomsg_la-cinproc.lo -MD -MP -MF src/transports/inproc/$(DEPDIR)/libnanomsg_la-cinproc.Tpo -c -o src/transports/inproc/libnanomsg_la-cinproc.lo `test -f 'src/transports/inproc/cinproc.c' || echo '$(srcdir)/'`src/transports/inproc/cinproc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/inproc/$(DEPDIR)/libnanomsg_la-cinproc.Tpo src/transports/inproc/$(DEPDIR)/libnanomsg_la-cinproc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/inproc/cinproc.c' object='src/transports/inproc/libnanomsg_la-cinproc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/inproc/libnanomsg_la-cinproc.lo `test -f 'src/transports/inproc/cinproc.c' || echo '$(srcdir)/'`src/transports/inproc/cinproc.c src/transports/inproc/libnanomsg_la-inproc.lo: src/transports/inproc/inproc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/inproc/libnanomsg_la-inproc.lo -MD -MP -MF src/transports/inproc/$(DEPDIR)/libnanomsg_la-inproc.Tpo -c -o src/transports/inproc/libnanomsg_la-inproc.lo `test -f 'src/transports/inproc/inproc.c' || echo '$(srcdir)/'`src/transports/inproc/inproc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/inproc/$(DEPDIR)/libnanomsg_la-inproc.Tpo src/transports/inproc/$(DEPDIR)/libnanomsg_la-inproc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/inproc/inproc.c' object='src/transports/inproc/libnanomsg_la-inproc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/inproc/libnanomsg_la-inproc.lo `test -f 'src/transports/inproc/inproc.c' || echo '$(srcdir)/'`src/transports/inproc/inproc.c src/transports/inproc/libnanomsg_la-ins.lo: src/transports/inproc/ins.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/inproc/libnanomsg_la-ins.lo -MD -MP -MF src/transports/inproc/$(DEPDIR)/libnanomsg_la-ins.Tpo -c -o src/transports/inproc/libnanomsg_la-ins.lo `test -f 'src/transports/inproc/ins.c' || echo '$(srcdir)/'`src/transports/inproc/ins.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/inproc/$(DEPDIR)/libnanomsg_la-ins.Tpo src/transports/inproc/$(DEPDIR)/libnanomsg_la-ins.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/inproc/ins.c' object='src/transports/inproc/libnanomsg_la-ins.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/inproc/libnanomsg_la-ins.lo `test -f 'src/transports/inproc/ins.c' || echo '$(srcdir)/'`src/transports/inproc/ins.c src/transports/inproc/libnanomsg_la-msgqueue.lo: src/transports/inproc/msgqueue.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/inproc/libnanomsg_la-msgqueue.lo -MD -MP -MF src/transports/inproc/$(DEPDIR)/libnanomsg_la-msgqueue.Tpo -c -o src/transports/inproc/libnanomsg_la-msgqueue.lo `test -f 'src/transports/inproc/msgqueue.c' || echo '$(srcdir)/'`src/transports/inproc/msgqueue.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/inproc/$(DEPDIR)/libnanomsg_la-msgqueue.Tpo src/transports/inproc/$(DEPDIR)/libnanomsg_la-msgqueue.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/inproc/msgqueue.c' object='src/transports/inproc/libnanomsg_la-msgqueue.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/inproc/libnanomsg_la-msgqueue.lo `test -f 'src/transports/inproc/msgqueue.c' || echo '$(srcdir)/'`src/transports/inproc/msgqueue.c src/transports/inproc/libnanomsg_la-sinproc.lo: src/transports/inproc/sinproc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/inproc/libnanomsg_la-sinproc.lo -MD -MP -MF src/transports/inproc/$(DEPDIR)/libnanomsg_la-sinproc.Tpo -c -o src/transports/inproc/libnanomsg_la-sinproc.lo `test -f 'src/transports/inproc/sinproc.c' || echo '$(srcdir)/'`src/transports/inproc/sinproc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/inproc/$(DEPDIR)/libnanomsg_la-sinproc.Tpo src/transports/inproc/$(DEPDIR)/libnanomsg_la-sinproc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/inproc/sinproc.c' object='src/transports/inproc/libnanomsg_la-sinproc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/inproc/libnanomsg_la-sinproc.lo `test -f 'src/transports/inproc/sinproc.c' || echo '$(srcdir)/'`src/transports/inproc/sinproc.c src/transports/ipc/libnanomsg_la-aipc.lo: src/transports/ipc/aipc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/ipc/libnanomsg_la-aipc.lo -MD -MP -MF src/transports/ipc/$(DEPDIR)/libnanomsg_la-aipc.Tpo -c -o src/transports/ipc/libnanomsg_la-aipc.lo `test -f 'src/transports/ipc/aipc.c' || echo '$(srcdir)/'`src/transports/ipc/aipc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/ipc/$(DEPDIR)/libnanomsg_la-aipc.Tpo src/transports/ipc/$(DEPDIR)/libnanomsg_la-aipc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/ipc/aipc.c' object='src/transports/ipc/libnanomsg_la-aipc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/ipc/libnanomsg_la-aipc.lo `test -f 'src/transports/ipc/aipc.c' || echo '$(srcdir)/'`src/transports/ipc/aipc.c src/transports/ipc/libnanomsg_la-bipc.lo: src/transports/ipc/bipc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/ipc/libnanomsg_la-bipc.lo -MD -MP -MF src/transports/ipc/$(DEPDIR)/libnanomsg_la-bipc.Tpo -c -o src/transports/ipc/libnanomsg_la-bipc.lo `test -f 'src/transports/ipc/bipc.c' || echo '$(srcdir)/'`src/transports/ipc/bipc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/ipc/$(DEPDIR)/libnanomsg_la-bipc.Tpo src/transports/ipc/$(DEPDIR)/libnanomsg_la-bipc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/ipc/bipc.c' object='src/transports/ipc/libnanomsg_la-bipc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/ipc/libnanomsg_la-bipc.lo `test -f 'src/transports/ipc/bipc.c' || echo '$(srcdir)/'`src/transports/ipc/bipc.c src/transports/ipc/libnanomsg_la-cipc.lo: src/transports/ipc/cipc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/ipc/libnanomsg_la-cipc.lo -MD -MP -MF src/transports/ipc/$(DEPDIR)/libnanomsg_la-cipc.Tpo -c -o src/transports/ipc/libnanomsg_la-cipc.lo `test -f 'src/transports/ipc/cipc.c' || echo '$(srcdir)/'`src/transports/ipc/cipc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/ipc/$(DEPDIR)/libnanomsg_la-cipc.Tpo src/transports/ipc/$(DEPDIR)/libnanomsg_la-cipc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/ipc/cipc.c' object='src/transports/ipc/libnanomsg_la-cipc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/ipc/libnanomsg_la-cipc.lo `test -f 'src/transports/ipc/cipc.c' || echo '$(srcdir)/'`src/transports/ipc/cipc.c src/transports/ipc/libnanomsg_la-ipc.lo: src/transports/ipc/ipc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/ipc/libnanomsg_la-ipc.lo -MD -MP -MF src/transports/ipc/$(DEPDIR)/libnanomsg_la-ipc.Tpo -c -o src/transports/ipc/libnanomsg_la-ipc.lo `test -f 'src/transports/ipc/ipc.c' || echo '$(srcdir)/'`src/transports/ipc/ipc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/ipc/$(DEPDIR)/libnanomsg_la-ipc.Tpo src/transports/ipc/$(DEPDIR)/libnanomsg_la-ipc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/ipc/ipc.c' object='src/transports/ipc/libnanomsg_la-ipc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/ipc/libnanomsg_la-ipc.lo `test -f 'src/transports/ipc/ipc.c' || echo '$(srcdir)/'`src/transports/ipc/ipc.c src/transports/ipc/libnanomsg_la-sipc.lo: src/transports/ipc/sipc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/ipc/libnanomsg_la-sipc.lo -MD -MP -MF src/transports/ipc/$(DEPDIR)/libnanomsg_la-sipc.Tpo -c -o src/transports/ipc/libnanomsg_la-sipc.lo `test -f 'src/transports/ipc/sipc.c' || echo '$(srcdir)/'`src/transports/ipc/sipc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/ipc/$(DEPDIR)/libnanomsg_la-sipc.Tpo src/transports/ipc/$(DEPDIR)/libnanomsg_la-sipc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/ipc/sipc.c' object='src/transports/ipc/libnanomsg_la-sipc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/ipc/libnanomsg_la-sipc.lo `test -f 'src/transports/ipc/sipc.c' || echo '$(srcdir)/'`src/transports/ipc/sipc.c src/transports/tcp/libnanomsg_la-atcp.lo: src/transports/tcp/atcp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/tcp/libnanomsg_la-atcp.lo -MD -MP -MF src/transports/tcp/$(DEPDIR)/libnanomsg_la-atcp.Tpo -c -o src/transports/tcp/libnanomsg_la-atcp.lo `test -f 'src/transports/tcp/atcp.c' || echo '$(srcdir)/'`src/transports/tcp/atcp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/tcp/$(DEPDIR)/libnanomsg_la-atcp.Tpo src/transports/tcp/$(DEPDIR)/libnanomsg_la-atcp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/tcp/atcp.c' object='src/transports/tcp/libnanomsg_la-atcp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/tcp/libnanomsg_la-atcp.lo `test -f 'src/transports/tcp/atcp.c' || echo '$(srcdir)/'`src/transports/tcp/atcp.c src/transports/tcp/libnanomsg_la-btcp.lo: src/transports/tcp/btcp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/tcp/libnanomsg_la-btcp.lo -MD -MP -MF src/transports/tcp/$(DEPDIR)/libnanomsg_la-btcp.Tpo -c -o src/transports/tcp/libnanomsg_la-btcp.lo `test -f 'src/transports/tcp/btcp.c' || echo '$(srcdir)/'`src/transports/tcp/btcp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/tcp/$(DEPDIR)/libnanomsg_la-btcp.Tpo src/transports/tcp/$(DEPDIR)/libnanomsg_la-btcp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/tcp/btcp.c' object='src/transports/tcp/libnanomsg_la-btcp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/tcp/libnanomsg_la-btcp.lo `test -f 'src/transports/tcp/btcp.c' || echo '$(srcdir)/'`src/transports/tcp/btcp.c src/transports/tcp/libnanomsg_la-ctcp.lo: src/transports/tcp/ctcp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/tcp/libnanomsg_la-ctcp.lo -MD -MP -MF src/transports/tcp/$(DEPDIR)/libnanomsg_la-ctcp.Tpo -c -o src/transports/tcp/libnanomsg_la-ctcp.lo `test -f 'src/transports/tcp/ctcp.c' || echo '$(srcdir)/'`src/transports/tcp/ctcp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/tcp/$(DEPDIR)/libnanomsg_la-ctcp.Tpo src/transports/tcp/$(DEPDIR)/libnanomsg_la-ctcp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/tcp/ctcp.c' object='src/transports/tcp/libnanomsg_la-ctcp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/tcp/libnanomsg_la-ctcp.lo `test -f 'src/transports/tcp/ctcp.c' || echo '$(srcdir)/'`src/transports/tcp/ctcp.c src/transports/tcp/libnanomsg_la-stcp.lo: src/transports/tcp/stcp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/tcp/libnanomsg_la-stcp.lo -MD -MP -MF src/transports/tcp/$(DEPDIR)/libnanomsg_la-stcp.Tpo -c -o src/transports/tcp/libnanomsg_la-stcp.lo `test -f 'src/transports/tcp/stcp.c' || echo '$(srcdir)/'`src/transports/tcp/stcp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/tcp/$(DEPDIR)/libnanomsg_la-stcp.Tpo src/transports/tcp/$(DEPDIR)/libnanomsg_la-stcp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/tcp/stcp.c' object='src/transports/tcp/libnanomsg_la-stcp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/tcp/libnanomsg_la-stcp.lo `test -f 'src/transports/tcp/stcp.c' || echo '$(srcdir)/'`src/transports/tcp/stcp.c src/transports/tcp/libnanomsg_la-tcp.lo: src/transports/tcp/tcp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/tcp/libnanomsg_la-tcp.lo -MD -MP -MF src/transports/tcp/$(DEPDIR)/libnanomsg_la-tcp.Tpo -c -o src/transports/tcp/libnanomsg_la-tcp.lo `test -f 'src/transports/tcp/tcp.c' || echo '$(srcdir)/'`src/transports/tcp/tcp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/tcp/$(DEPDIR)/libnanomsg_la-tcp.Tpo src/transports/tcp/$(DEPDIR)/libnanomsg_la-tcp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/tcp/tcp.c' object='src/transports/tcp/libnanomsg_la-tcp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/tcp/libnanomsg_la-tcp.lo `test -f 'src/transports/tcp/tcp.c' || echo '$(srcdir)/'`src/transports/tcp/tcp.c src/transports/ws/libnanomsg_la-aws.lo: src/transports/ws/aws.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/ws/libnanomsg_la-aws.lo -MD -MP -MF src/transports/ws/$(DEPDIR)/libnanomsg_la-aws.Tpo -c -o src/transports/ws/libnanomsg_la-aws.lo `test -f 'src/transports/ws/aws.c' || echo '$(srcdir)/'`src/transports/ws/aws.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/ws/$(DEPDIR)/libnanomsg_la-aws.Tpo src/transports/ws/$(DEPDIR)/libnanomsg_la-aws.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/ws/aws.c' object='src/transports/ws/libnanomsg_la-aws.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/ws/libnanomsg_la-aws.lo `test -f 'src/transports/ws/aws.c' || echo '$(srcdir)/'`src/transports/ws/aws.c src/transports/ws/libnanomsg_la-bws.lo: src/transports/ws/bws.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/ws/libnanomsg_la-bws.lo -MD -MP -MF src/transports/ws/$(DEPDIR)/libnanomsg_la-bws.Tpo -c -o src/transports/ws/libnanomsg_la-bws.lo `test -f 'src/transports/ws/bws.c' || echo '$(srcdir)/'`src/transports/ws/bws.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/ws/$(DEPDIR)/libnanomsg_la-bws.Tpo src/transports/ws/$(DEPDIR)/libnanomsg_la-bws.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/ws/bws.c' object='src/transports/ws/libnanomsg_la-bws.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/ws/libnanomsg_la-bws.lo `test -f 'src/transports/ws/bws.c' || echo '$(srcdir)/'`src/transports/ws/bws.c src/transports/ws/libnanomsg_la-cws.lo: src/transports/ws/cws.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/ws/libnanomsg_la-cws.lo -MD -MP -MF src/transports/ws/$(DEPDIR)/libnanomsg_la-cws.Tpo -c -o src/transports/ws/libnanomsg_la-cws.lo `test -f 'src/transports/ws/cws.c' || echo '$(srcdir)/'`src/transports/ws/cws.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/ws/$(DEPDIR)/libnanomsg_la-cws.Tpo src/transports/ws/$(DEPDIR)/libnanomsg_la-cws.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/ws/cws.c' object='src/transports/ws/libnanomsg_la-cws.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/ws/libnanomsg_la-cws.lo `test -f 'src/transports/ws/cws.c' || echo '$(srcdir)/'`src/transports/ws/cws.c src/transports/ws/libnanomsg_la-sws.lo: src/transports/ws/sws.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/ws/libnanomsg_la-sws.lo -MD -MP -MF src/transports/ws/$(DEPDIR)/libnanomsg_la-sws.Tpo -c -o src/transports/ws/libnanomsg_la-sws.lo `test -f 'src/transports/ws/sws.c' || echo '$(srcdir)/'`src/transports/ws/sws.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/ws/$(DEPDIR)/libnanomsg_la-sws.Tpo src/transports/ws/$(DEPDIR)/libnanomsg_la-sws.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/ws/sws.c' object='src/transports/ws/libnanomsg_la-sws.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/ws/libnanomsg_la-sws.lo `test -f 'src/transports/ws/sws.c' || echo '$(srcdir)/'`src/transports/ws/sws.c src/transports/ws/libnanomsg_la-ws.lo: src/transports/ws/ws.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/ws/libnanomsg_la-ws.lo -MD -MP -MF src/transports/ws/$(DEPDIR)/libnanomsg_la-ws.Tpo -c -o src/transports/ws/libnanomsg_la-ws.lo `test -f 'src/transports/ws/ws.c' || echo '$(srcdir)/'`src/transports/ws/ws.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/ws/$(DEPDIR)/libnanomsg_la-ws.Tpo src/transports/ws/$(DEPDIR)/libnanomsg_la-ws.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/ws/ws.c' object='src/transports/ws/libnanomsg_la-ws.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/ws/libnanomsg_la-ws.lo `test -f 'src/transports/ws/ws.c' || echo '$(srcdir)/'`src/transports/ws/ws.c src/transports/ws/libnanomsg_la-ws_handshake.lo: src/transports/ws/ws_handshake.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/ws/libnanomsg_la-ws_handshake.lo -MD -MP -MF src/transports/ws/$(DEPDIR)/libnanomsg_la-ws_handshake.Tpo -c -o src/transports/ws/libnanomsg_la-ws_handshake.lo `test -f 'src/transports/ws/ws_handshake.c' || echo '$(srcdir)/'`src/transports/ws/ws_handshake.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/ws/$(DEPDIR)/libnanomsg_la-ws_handshake.Tpo src/transports/ws/$(DEPDIR)/libnanomsg_la-ws_handshake.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/ws/ws_handshake.c' object='src/transports/ws/libnanomsg_la-ws_handshake.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/ws/libnanomsg_la-ws_handshake.lo `test -f 'src/transports/ws/ws_handshake.c' || echo '$(srcdir)/'`src/transports/ws/ws_handshake.c src/transports/ws/libnanomsg_la-sha1.lo: src/transports/ws/sha1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/ws/libnanomsg_la-sha1.lo -MD -MP -MF src/transports/ws/$(DEPDIR)/libnanomsg_la-sha1.Tpo -c -o src/transports/ws/libnanomsg_la-sha1.lo `test -f 'src/transports/ws/sha1.c' || echo '$(srcdir)/'`src/transports/ws/sha1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/ws/$(DEPDIR)/libnanomsg_la-sha1.Tpo src/transports/ws/$(DEPDIR)/libnanomsg_la-sha1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/ws/sha1.c' object='src/transports/ws/libnanomsg_la-sha1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/ws/libnanomsg_la-sha1.lo `test -f 'src/transports/ws/sha1.c' || echo '$(srcdir)/'`src/transports/ws/sha1.c src/transports/tcpmux/libnanomsg_la-atcpmux.lo: src/transports/tcpmux/atcpmux.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/tcpmux/libnanomsg_la-atcpmux.lo -MD -MP -MF src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-atcpmux.Tpo -c -o src/transports/tcpmux/libnanomsg_la-atcpmux.lo `test -f 'src/transports/tcpmux/atcpmux.c' || echo '$(srcdir)/'`src/transports/tcpmux/atcpmux.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-atcpmux.Tpo src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-atcpmux.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/tcpmux/atcpmux.c' object='src/transports/tcpmux/libnanomsg_la-atcpmux.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/tcpmux/libnanomsg_la-atcpmux.lo `test -f 'src/transports/tcpmux/atcpmux.c' || echo '$(srcdir)/'`src/transports/tcpmux/atcpmux.c src/transports/tcpmux/libnanomsg_la-btcpmux.lo: src/transports/tcpmux/btcpmux.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/tcpmux/libnanomsg_la-btcpmux.lo -MD -MP -MF src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-btcpmux.Tpo -c -o src/transports/tcpmux/libnanomsg_la-btcpmux.lo `test -f 'src/transports/tcpmux/btcpmux.c' || echo '$(srcdir)/'`src/transports/tcpmux/btcpmux.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-btcpmux.Tpo src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-btcpmux.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/tcpmux/btcpmux.c' object='src/transports/tcpmux/libnanomsg_la-btcpmux.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/tcpmux/libnanomsg_la-btcpmux.lo `test -f 'src/transports/tcpmux/btcpmux.c' || echo '$(srcdir)/'`src/transports/tcpmux/btcpmux.c src/transports/tcpmux/libnanomsg_la-ctcpmux.lo: src/transports/tcpmux/ctcpmux.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/tcpmux/libnanomsg_la-ctcpmux.lo -MD -MP -MF src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-ctcpmux.Tpo -c -o src/transports/tcpmux/libnanomsg_la-ctcpmux.lo `test -f 'src/transports/tcpmux/ctcpmux.c' || echo '$(srcdir)/'`src/transports/tcpmux/ctcpmux.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-ctcpmux.Tpo src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-ctcpmux.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/tcpmux/ctcpmux.c' object='src/transports/tcpmux/libnanomsg_la-ctcpmux.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/tcpmux/libnanomsg_la-ctcpmux.lo `test -f 'src/transports/tcpmux/ctcpmux.c' || echo '$(srcdir)/'`src/transports/tcpmux/ctcpmux.c src/transports/tcpmux/libnanomsg_la-stcpmux.lo: src/transports/tcpmux/stcpmux.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/tcpmux/libnanomsg_la-stcpmux.lo -MD -MP -MF src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-stcpmux.Tpo -c -o src/transports/tcpmux/libnanomsg_la-stcpmux.lo `test -f 'src/transports/tcpmux/stcpmux.c' || echo '$(srcdir)/'`src/transports/tcpmux/stcpmux.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-stcpmux.Tpo src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-stcpmux.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/tcpmux/stcpmux.c' object='src/transports/tcpmux/libnanomsg_la-stcpmux.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/tcpmux/libnanomsg_la-stcpmux.lo `test -f 'src/transports/tcpmux/stcpmux.c' || echo '$(srcdir)/'`src/transports/tcpmux/stcpmux.c src/transports/tcpmux/libnanomsg_la-tcpmux.lo: src/transports/tcpmux/tcpmux.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/transports/tcpmux/libnanomsg_la-tcpmux.lo -MD -MP -MF src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-tcpmux.Tpo -c -o src/transports/tcpmux/libnanomsg_la-tcpmux.lo `test -f 'src/transports/tcpmux/tcpmux.c' || echo '$(srcdir)/'`src/transports/tcpmux/tcpmux.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-tcpmux.Tpo src/transports/tcpmux/$(DEPDIR)/libnanomsg_la-tcpmux.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/transports/tcpmux/tcpmux.c' object='src/transports/tcpmux/libnanomsg_la-tcpmux.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/transports/tcpmux/libnanomsg_la-tcpmux.lo `test -f 'src/transports/tcpmux/tcpmux.c' || echo '$(srcdir)/'`src/transports/tcpmux/tcpmux.c src/devices/libnanomsg_la-device.lo: src/devices/device.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/devices/libnanomsg_la-device.lo -MD -MP -MF src/devices/$(DEPDIR)/libnanomsg_la-device.Tpo -c -o src/devices/libnanomsg_la-device.lo `test -f 'src/devices/device.c' || echo '$(srcdir)/'`src/devices/device.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/devices/$(DEPDIR)/libnanomsg_la-device.Tpo src/devices/$(DEPDIR)/libnanomsg_la-device.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/devices/device.c' object='src/devices/libnanomsg_la-device.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/devices/libnanomsg_la-device.lo `test -f 'src/devices/device.c' || echo '$(srcdir)/'`src/devices/device.c src/devices/libnanomsg_la-tcpmuxd.lo: src/devices/tcpmuxd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -MT src/devices/libnanomsg_la-tcpmuxd.lo -MD -MP -MF src/devices/$(DEPDIR)/libnanomsg_la-tcpmuxd.Tpo -c -o src/devices/libnanomsg_la-tcpmuxd.lo `test -f 'src/devices/tcpmuxd.c' || echo '$(srcdir)/'`src/devices/tcpmuxd.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/devices/$(DEPDIR)/libnanomsg_la-tcpmuxd.Tpo src/devices/$(DEPDIR)/libnanomsg_la-tcpmuxd.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/devices/tcpmuxd.c' object='src/devices/libnanomsg_la-tcpmuxd.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnanomsg_la_CFLAGS) $(CFLAGS) -c -o src/devices/libnanomsg_la-tcpmuxd.lo `test -f 'src/devices/tcpmuxd.c' || echo '$(srcdir)/'`src/devices/tcpmuxd.c mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -rm -rf perf/.libs perf/_libs -rm -rf src/aio/.libs src/aio/_libs -rm -rf src/core/.libs src/core/_libs -rm -rf src/devices/.libs src/devices/_libs -rm -rf src/protocols/bus/.libs src/protocols/bus/_libs -rm -rf src/protocols/pair/.libs src/protocols/pair/_libs -rm -rf src/protocols/pipeline/.libs src/protocols/pipeline/_libs -rm -rf src/protocols/pubsub/.libs src/protocols/pubsub/_libs -rm -rf src/protocols/reqrep/.libs src/protocols/reqrep/_libs -rm -rf src/protocols/survey/.libs src/protocols/survey/_libs -rm -rf src/protocols/utils/.libs src/protocols/utils/_libs -rm -rf src/transports/inproc/.libs src/transports/inproc/_libs -rm -rf src/transports/ipc/.libs src/transports/ipc/_libs -rm -rf src/transports/tcp/.libs src/transports/tcp/_libs -rm -rf src/transports/tcpmux/.libs src/transports/tcpmux/_libs -rm -rf src/transports/utils/.libs src/transports/utils/_libs -rm -rf src/transports/ws/.libs src/transports/ws/_libs -rm -rf src/utils/.libs src/utils/_libs -rm -rf tests/.libs tests/_libs distclean-libtool: -rm -f libtool config.lt install-man1: $(dist_man1_MANS) @$(NORMAL_INSTALL) test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" @list='$(dist_man1_MANS)'; test -n "$(man1dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list='$(dist_man1_MANS)'; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) install-man3: $(dist_man3_MANS) @$(NORMAL_INSTALL) test -z "$(man3dir)" || $(MKDIR_P) "$(DESTDIR)$(man3dir)" @list='$(dist_man3_MANS)'; test -n "$(man3dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \ done; } uninstall-man3: @$(NORMAL_UNINSTALL) @list='$(dist_man3_MANS)'; test -n "$(man3dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir) install-man7: $(dist_man7_MANS) @$(NORMAL_INSTALL) test -z "$(man7dir)" || $(MKDIR_P) "$(DESTDIR)$(man7dir)" @list='$(dist_man7_MANS)'; test -n "$(man7dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^7][0-9a-z]*$$,7,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man7dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man7dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man7dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man7dir)" || exit $$?; }; \ done; } uninstall-man7: @$(NORMAL_UNINSTALL) @list='$(dist_man7_MANS)'; test -n "$(man7dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^7][0-9a-z]*$$,7,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man7dir)'; $(am__uninstall_files_from_dir) install-htmlDATA: $(html_DATA) @$(NORMAL_INSTALL) test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)" @list='$(html_DATA)'; test -n "$(htmldir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(htmldir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(htmldir)" || exit $$?; \ done uninstall-htmlDATA: @$(NORMAL_UNINSTALL) @list='$(html_DATA)'; test -n "$(htmldir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(htmldir)'; $(am__uninstall_files_from_dir) install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ done uninstall-pkgconfigDATA: @$(NORMAL_UNINSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) install-nnincludeHEADERS: $(nninclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(nnincludedir)" || $(MKDIR_P) "$(DESTDIR)$(nnincludedir)" @list='$(nninclude_HEADERS)'; test -n "$(nnincludedir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(nnincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(nnincludedir)" || exit $$?; \ done uninstall-nnincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(nninclude_HEADERS)'; test -n "$(nnincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(nnincludedir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ $(am__tty_colors); \ if test -n "$$list"; then \ for tst in $$list; do \ if test -f ./$$tst; then dir=./; \ elif test -f $$tst; then dir=; \ else dir="$(srcdir)/"; fi; \ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xpass=`expr $$xpass + 1`; \ failed=`expr $$failed + 1`; \ col=$$red; res=XPASS; \ ;; \ *) \ col=$$grn; res=PASS; \ ;; \ esac; \ elif test $$? -ne 77; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xfail=`expr $$xfail + 1`; \ col=$$lgn; res=XFAIL; \ ;; \ *) \ failed=`expr $$failed + 1`; \ col=$$red; res=FAIL; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ col=$$blu; res=SKIP; \ fi; \ echo "$${col}$$res$${std}: $$tst"; \ done; \ if test "$$all" -eq 1; then \ tests="test"; \ All=""; \ else \ tests="tests"; \ All="All "; \ fi; \ if test "$$failed" -eq 0; then \ if test "$$xfail" -eq 0; then \ banner="$$All$$all $$tests passed"; \ else \ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ fi; \ else \ if test "$$xpass" -eq 0; then \ banner="$$failed of $$all $$tests failed"; \ else \ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ fi; \ fi; \ dashes="$$banner"; \ skipped=""; \ if test "$$skip" -ne 0; then \ if test "$$skip" -eq 1; then \ skipped="($$skip test was not run)"; \ else \ skipped="($$skip tests were not run)"; \ fi; \ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$skipped"; \ fi; \ report=""; \ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ report="Please report to $(PACKAGE_BUGREPORT)"; \ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$report"; \ fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ col="$$grn"; \ else \ col="$$red"; \ fi; \ echo "$${col}$$dashes$${std}"; \ echo "$${col}$$banner$${std}"; \ test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ test -z "$$report" || echo "$${col}$$report$${std}"; \ echo "$${col}$$dashes$${std}"; \ test "$$failed" -eq 0; \ else :; fi distdir: $(DISTFILES) @list='$(MANS)'; if test -n "$$list"; then \ list=`for p in $$list; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ if test -n "$$list" && \ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ echo " typically \`make maintainer-clean' will remove them" >&2; \ exit 1; \ else :; fi; \ else :; fi $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(MANS) $(DATA) $(HEADERS) install-binPROGRAMS: install-libLTLIBRARIES installdirs: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(man7dir)" "$(DESTDIR)$(htmldir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(nnincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f perf/$(DEPDIR)/$(am__dirstamp) -rm -f perf/$(am__dirstamp) -rm -f src/aio/$(DEPDIR)/$(am__dirstamp) -rm -f src/aio/$(am__dirstamp) -rm -f src/core/$(DEPDIR)/$(am__dirstamp) -rm -f src/core/$(am__dirstamp) -rm -f src/devices/$(DEPDIR)/$(am__dirstamp) -rm -f src/devices/$(am__dirstamp) -rm -f src/protocols/bus/$(DEPDIR)/$(am__dirstamp) -rm -f src/protocols/bus/$(am__dirstamp) -rm -f src/protocols/pair/$(DEPDIR)/$(am__dirstamp) -rm -f src/protocols/pair/$(am__dirstamp) -rm -f src/protocols/pipeline/$(DEPDIR)/$(am__dirstamp) -rm -f src/protocols/pipeline/$(am__dirstamp) -rm -f src/protocols/pubsub/$(DEPDIR)/$(am__dirstamp) -rm -f src/protocols/pubsub/$(am__dirstamp) -rm -f src/protocols/reqrep/$(DEPDIR)/$(am__dirstamp) -rm -f src/protocols/reqrep/$(am__dirstamp) -rm -f src/protocols/survey/$(DEPDIR)/$(am__dirstamp) -rm -f src/protocols/survey/$(am__dirstamp) -rm -f src/protocols/utils/$(DEPDIR)/$(am__dirstamp) -rm -f src/protocols/utils/$(am__dirstamp) -rm -f src/transports/inproc/$(DEPDIR)/$(am__dirstamp) -rm -f src/transports/inproc/$(am__dirstamp) -rm -f src/transports/ipc/$(DEPDIR)/$(am__dirstamp) -rm -f src/transports/ipc/$(am__dirstamp) -rm -f src/transports/tcp/$(DEPDIR)/$(am__dirstamp) -rm -f src/transports/tcp/$(am__dirstamp) -rm -f src/transports/tcpmux/$(DEPDIR)/$(am__dirstamp) -rm -f src/transports/tcpmux/$(am__dirstamp) -rm -f src/transports/utils/$(DEPDIR)/$(am__dirstamp) -rm -f src/transports/utils/$(am__dirstamp) -rm -f src/transports/ws/$(DEPDIR)/$(am__dirstamp) -rm -f src/transports/ws/$(am__dirstamp) -rm -f src/utils/$(DEPDIR)/$(am__dirstamp) -rm -f src/utils/$(am__dirstamp) -rm -f tests/$(DEPDIR)/$(am__dirstamp) -rm -f tests/$(am__dirstamp) -rm -f tools/$(DEPDIR)/$(am__dirstamp) -rm -f tools/$(am__dirstamp) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." @NANOCAT_FALSE@install-exec-hook: @SYMLINKS_FALSE@install-exec-hook: @NANOCAT_FALSE@uninstall-hook: @SYMLINKS_FALSE@uninstall-hook: clean: clean-am clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ clean-libLTLIBRARIES clean-libtool clean-local \ clean-noinstPROGRAMS mostlyclean-am distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf perf/$(DEPDIR) src/aio/$(DEPDIR) src/core/$(DEPDIR) src/devices/$(DEPDIR) src/protocols/bus/$(DEPDIR) src/protocols/pair/$(DEPDIR) src/protocols/pipeline/$(DEPDIR) src/protocols/pubsub/$(DEPDIR) src/protocols/reqrep/$(DEPDIR) src/protocols/survey/$(DEPDIR) src/protocols/utils/$(DEPDIR) src/transports/inproc/$(DEPDIR) src/transports/ipc/$(DEPDIR) src/transports/tcp/$(DEPDIR) src/transports/tcpmux/$(DEPDIR) src/transports/utils/$(DEPDIR) src/transports/ws/$(DEPDIR) src/utils/$(DEPDIR) tests/$(DEPDIR) tools/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-libtool distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-htmlDATA install-man install-nnincludeHEADERS \ install-pkgconfigDATA install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-libLTLIBRARIES @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-exec-hook install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man1 install-man3 install-man7 install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -rf perf/$(DEPDIR) src/aio/$(DEPDIR) src/core/$(DEPDIR) src/devices/$(DEPDIR) src/protocols/bus/$(DEPDIR) src/protocols/pair/$(DEPDIR) src/protocols/pipeline/$(DEPDIR) src/protocols/pubsub/$(DEPDIR) src/protocols/reqrep/$(DEPDIR) src/protocols/survey/$(DEPDIR) src/protocols/utils/$(DEPDIR) src/transports/inproc/$(DEPDIR) src/transports/ipc/$(DEPDIR) src/transports/tcp/$(DEPDIR) src/transports/tcpmux/$(DEPDIR) src/transports/utils/$(DEPDIR) src/transports/ws/$(DEPDIR) src/utils/$(DEPDIR) tests/$(DEPDIR) tools/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-htmlDATA \ uninstall-libLTLIBRARIES uninstall-man \ uninstall-nnincludeHEADERS uninstall-pkgconfigDATA @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-hook uninstall-man: uninstall-man1 uninstall-man3 uninstall-man7 .MAKE: check-am install-am install-exec-am install-strip uninstall-am .PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \ clean clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ clean-libLTLIBRARIES clean-libtool clean-local \ clean-noinstPROGRAMS ctags dist dist-all dist-bzip2 dist-gzip \ dist-hook dist-lzip dist-lzma dist-shar dist-tarZ dist-xz \ dist-zip distcheck distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags \ distcleancheck distdir distuninstallcheck dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-exec-hook install-html \ install-html-am install-htmlDATA install-info install-info-am \ install-libLTLIBRARIES install-man install-man1 install-man3 \ install-man7 install-nnincludeHEADERS install-pdf \ install-pdf-am install-pkgconfigDATA install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags uninstall uninstall-am \ uninstall-binPROGRAMS uninstall-hook uninstall-htmlDATA \ uninstall-libLTLIBRARIES uninstall-man uninstall-man1 \ uninstall-man3 uninstall-man7 uninstall-nnincludeHEADERS \ uninstall-pkgconfigDATA # Build instructions. @DOC_TRUE@.txt.xml: @DOC_TRUE@ $(AM_V_GEN)$(ASCIIDOC) -d manpage -b docbook \ @DOC_TRUE@ -f $(abs_srcdir)/doc/asciidoc.conf \ @DOC_TRUE@ -aversion=@NN_PACKAGE_VERSION@ -o $@ $< @DOC_TRUE@.xml.1: @DOC_TRUE@ $(AM_V_GEN)$(XMLTO) -o doc man $< @DOC_TRUE@.xml.3: @DOC_TRUE@ $(AM_V_GEN)$(XMLTO) -o doc man $< @DOC_TRUE@.xml.7: @DOC_TRUE@ $(AM_V_GEN)$(XMLTO) -o doc man $< @DOC_TRUE@.txt.1.html: @DOC_TRUE@ $(AM_V_GEN)$(ASCIIDOC) -d manpage -b xhtml11 \ @DOC_TRUE@ -a stylesheet=$(abs_srcdir)/doc/htmldoc.css \ @DOC_TRUE@ -f $(abs_srcdir)/doc/asciidoc.conf \ @DOC_TRUE@ -aversion=@NN_PACKAGE_VERSION@ -o $@ $< @DOC_TRUE@.txt.3.html: @DOC_TRUE@ $(AM_V_GEN)$(ASCIIDOC) -d manpage -b xhtml11 \ @DOC_TRUE@ -a stylesheet=$(abs_srcdir)/doc/htmldoc.css \ @DOC_TRUE@ -f $(abs_srcdir)/doc/asciidoc.conf \ @DOC_TRUE@ -aversion=@NN_PACKAGE_VERSION@ -o $@ $< @DOC_TRUE@.txt.7.html: @DOC_TRUE@ $(AM_V_GEN)$(ASCIIDOC) -d manpage -b xhtml11 \ @DOC_TRUE@ -a stylesheet=$(abs_srcdir)/doc/htmldoc.css \ @DOC_TRUE@ -f $(abs_srcdir)/doc/asciidoc.conf \ @DOC_TRUE@ -aversion=@NN_PACKAGE_VERSION@ -o $@ $< ################################################################################ # additional packaging-related stuff # ################################################################################ # Generate ChangeLog file from git. # Also, there's no git availabe when building from the source package and # thus no way to obtain package version. Therefore, package version is # saved into a file when building a source package. dist-hook: $(srcdir)/package_version.sh > $(distdir)/.version @NANOCAT_TRUE@@SYMLINKS_TRUE@install-exec-hook: @NANOCAT_TRUE@@SYMLINKS_TRUE@ cd $(DESTDIR)$(bindir) && \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ $(LN_S) -f nanocat nn_push$(EXEEXT) && \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ $(LN_S) -f nanocat nn_pull$(EXEEXT) && \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ $(LN_S) -f nanocat nn_pub$(EXEEXT) && \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ $(LN_S) -f nanocat nn_sub$(EXEEXT) && \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ $(LN_S) -f nanocat nn_req$(EXEEXT) && \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ $(LN_S) -f nanocat nn_rep$(EXEEXT) && \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ $(LN_S) -f nanocat nn_surveyor$(EXEEXT) && \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ $(LN_S) -f nanocat nn_respondent$(EXEEXT) && \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ $(LN_S) -f nanocat nn_bus$(EXEEXT) && \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ $(LN_S) -f nanocat nn_pair$(EXEEXT) @NANOCAT_TRUE@@SYMLINKS_TRUE@uninstall-hook: @NANOCAT_TRUE@@SYMLINKS_TRUE@ cd $(DESTDIR)$(bindir) && \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ rm -f nn_push$(EXEEXT) ; \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ rm -f nn_pull$(EXEEXT) ; \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ rm -f nn_pub$(EXEEXT) ; \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ rm -f nn_sub$(EXEEXT) ; \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ rm -f nn_req$(EXEEXT) ; \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ rm -f nn_rep$(EXEEXT) ; \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ rm -f nn_surveyor$(EXEEXT) ; \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ rm -f nn_respondent$(EXEEXT) ; \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ rm -f nn_bus$(EXEEXT) ; \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ rm -f nn_pair$(EXEEXT) @NANOCAT_TRUE@@SYMLINKS_TRUE@ cd $(DESTDIR)$(libdir) && \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ rm -f libnanomsg.* @NANOCAT_TRUE@@SYMLINKS_TRUE@ cd $(DESTDIR)$(includedir) && \ @NANOCAT_TRUE@@SYMLINKS_TRUE@ rm -rf nanomsg diagrams: -mkdir -p doc/diagrams $(abs_srcdir)/doc/diag.py $(DEFS) $(CPPFLAGS) \ $(shell clang -E - -v < /dev/null 2>&1 | \ sed -n '/#include . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: nanomsg@freelists.org about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='nanomsg' PACKAGE_TARNAME='nanomsg' PACKAGE_VERSION='0.8-beta' PACKAGE_STRING='nanomsg 0.8-beta' PACKAGE_BUGREPORT='nanomsg@freelists.org' PACKAGE_URL='http://nanomsg.org/' ac_unique_file="src/nn.h" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS LTCXXCOMPILE LTCOMPILE DOLT_CLEANFILES DOLT_BASH OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR DLLTOOL OBJDUMP NM ac_ct_DUMPBIN DUMPBIN LD FGREP LIBTOOL EGREP GREP CPP PTHREAD_CFLAGS PTHREAD_LIBS PTHREAD_CC ax_pthread_config TCPMUXD_FALSE TCPMUXD_TRUE SYMLINKS_FALSE SYMLINKS_TRUE NANOCAT_FALSE NANOCAT_TRUE LN_S DOC_FALSE DOC_TRUE XMLTO ASCIIDOC am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC NN_LIBTOOL_VERSION NN_PACKAGE_VERSION NN_ABI_VERSION SED host_os host_vendor host_cpu host build_os build_vendor build_cpu build AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking enable_debug enable_doc enable_nanocat enable_symlinks enable_tcpmuxd enable_getaddrinfo_a enable_shared enable_static with_pic enable_fast_install with_gnu_ld with_sysroot enable_libtool_lock ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures nanomsg 0.8-beta to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/nanomsg] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of nanomsg 0.8-beta:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: `make V=1') --disable-silent-rules verbose build output (undo: `make V=0') --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --enable-debug Enable debugging information [default=no] --enable-doc Build documentation [default=no] --enable-nanocat Build nanocat executable [default=yes] --enable-symlinks Make nn_xxx symlinks for nanocat [default=yes] --enable-tcpmuxd Build tcpmuxd executable [default=yes] --enable-getaddrinfo_a Use getaddrinfo_a if available [default=yes] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . nanomsg home page: . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF nanomsg configure 0.8-beta generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------ ## ## Report this to nanomsg@freelists.org ## ## ------------------------------------ ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by nanomsg $as_me 0.8-beta, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am__api_version='1.11' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # 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]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; 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". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` 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= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi 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 # 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. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi 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 if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 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 # Define the identity of the package. PACKAGE='nanomsg' VERSION='0.8-beta' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to create a ustar tar archive" >&5 $as_echo_n "checking how to create a ustar tar archive... " >&6; } # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar plaintar pax cpio none' _am_tools=${am_cv_prog_tar_ustar-$_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 { echo "$as_me:$LINENO: $_am_tar --version" >&5 ($_am_tar --version) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && break done am__tar="$_am_tar --format=ustar -chf - "'"$$tardir"' am__tar_="$_am_tar --format=ustar -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 ustar -w "$$tardir"' am__tar_='pax -L -x ustar -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H ustar -L' am__tar_='find "$tardir" -print | cpio -o -H ustar -L' am__untar='cpio -i -H ustar -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_ustar}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file { echo "$as_me:$LINENO: tardir=conftest.dir && eval $am__tar_ >conftest.tar" >&5 (tardir=conftest.dir && eval $am__tar_ >conftest.tar) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } rm -rf conftest.dir if test -s conftest.tar; then { echo "$as_me:$LINENO: $am__untar &5 ($am__untar &5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } grep GrepMe conftest.dir/file >/dev/null 2>&1 && break fi done rm -rf conftest.dir if ${am_cv_prog_tar_ustar+:} false; then : $as_echo_n "(cached) " >&6 else am_cv_prog_tar_ustar=$_am_tool fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_tar_ustar" >&5 $as_echo "$am_cv_prog_tar_ustar" >&6; } # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=0;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac ################################################################################ # Retrieve the versions. # ################################################################################ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done NN_ABI_VERSION=4.0.0 NN_PACKAGE_VERSION=0.8-beta NN_LIBTOOL_VERSION=4:0:0 { $as_echo "$as_me:${as_lineno-$LINENO}: nanomsg package version: $NN_PACKAGE_VERSION" >&5 $as_echo "$as_me: nanomsg package version: $NN_PACKAGE_VERSION" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: nanomsg ABI version: $NN_ABI_VERSION" >&5 $as_echo "$as_me: nanomsg ABI version: $NN_ABI_VERSION" >&6;} ################################################################################ # Check the compilers. # ################################################################################ DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" 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. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } 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 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else 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'. rm -rf conftest.dir 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_CC_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 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 ;; msvc7 | msvc7msys | 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_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5 $as_echo_n "checking for $CC option to accept ISO C99... " >&6; } if ${ac_cv_prog_cc_c99+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c99=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include // Check varargs macros. These examples are taken from C99 6.10.3.5. #define debug(...) fprintf (stderr, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK your preprocessor is broken; #endif #if BIG_OK #else your preprocessor is broken; #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\0'; ++i) continue; return 0; } // Check varargs and va_copy. static void test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str; int number; float fnumber; while (*format) { switch (*format++) { case 's': // string str = va_arg (args_copy, const char *); break; case 'd': // int number = va_arg (args_copy, int); break; case 'f': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); } int main () { // Check bool. _Bool success = false; // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. test_varargs ("s, d' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' || dynamic_array[ni.number - 1] != 543); ; return 0; } _ACEOF for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -xc99=all -qlanglvl=extc99 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c99=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c99" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c99" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 $as_echo "$ac_cv_prog_cc_c99" >&6; } ;; esac if test "x$ac_cv_prog_cc_c99" != xno; then : fi if test "x$CC" != xcc; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 $as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 $as_echo_n "checking whether cc understands -c and -o together... " >&6; } fi set dummy $CC; ac_cc=`$as_echo "$2" | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # We do the test twice because some compilers refuse to overwrite an # existing .o file with -o, though they will create one. ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then eval ac_cv_prog_cc_${ac_cc}_c_o=yes if test "x$CC" != xcc; then # Test first that cc exists at all. if { ac_try='cc -c conftest.$ac_ext >&5' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # cc works too. : else # cc exists but doesn't like -o. eval ac_cv_prog_cc_${ac_cc}_c_o=no fi fi fi else eval ac_cv_prog_cc_${ac_cc}_c_o=no fi rm -f core conftest* fi if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h fi # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ################################################################################ # Check whether GCC compiler is used. # ################################################################################ if test x"$GCC" = xyes; then : $as_echo "#define NN_HAVE_GCC 1" >>confdefs.h fi ################################################################################ # Check whether ICC compiler is used. # ################################################################################ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using ICC compiler" >&5 $as_echo_n "checking whether we are using ICC compiler... " >&6; } if ${ac_cv_icc_compiler+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __INTEL_COMPILER #error #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_icc_compiler=yes else ac_icc_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_icc_compiler=$ac_icc_compiler fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_icc_compiler" >&5 $as_echo "$ac_cv_icc_compiler" >&6; } if test x"$ac_cv_icc_compiler" = xyes; then : $as_echo "#define NN_HAVE_ICC 1" >>confdefs.h fi ################################################################################ # Check whether Sun Studio compiler is used. # ################################################################################ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using Sun Studio compiler" >&5 $as_echo_n "checking whether we are using Sun Studio compiler... " >&6; } if ${ac_cv_sun_studio_compiler+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __SUNPRO_C #error #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_sun_studio_compiler=yes else ac_sun_studio_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sun_studio_compiler=$ac_sun_studio_compiler fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sun_studio_compiler" >&5 $as_echo "$ac_cv_sun_studio_compiler" >&6; } if test x"$ac_cv_sun_studio_compiler" = xyes; then : $as_echo "#define NN_HAVE_SUN_STUDIO 1" >>confdefs.h fi ################################################################################ # Check whether clang compiler is used. # ################################################################################ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using clang compiler" >&5 $as_echo_n "checking whether we are using clang compiler... " >&6; } if ${ac_cv_clang_compiler+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __clang__ #error #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_clang_compiler=yes else ac_clang_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_clang_compiler=$ac_clang_compiler fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_clang_compiler" >&5 $as_echo "$ac_cv_clang_compiler" >&6; } if test x"$ac_cv_clang_compiler" = xyes; then : $as_echo "#define NN_HAVE_CLANG 1" >>confdefs.h fi ################################################################################ # Check whether HP aCC compiler is used. # ################################################################################ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using HP aCC compiler" >&5 $as_echo_n "checking whether we are using HP aCC compiler... " >&6; } if ${ac_cv_hpacc_compiler+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __HP_cc #error #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hpacc_compiler=yes else ac_hpacc_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_hpacc_compiler=$ac_hpacc_compiler fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_hpacc_compiler" >&5 $as_echo "$ac_cv_hpacc_compiler" >&6; } if test x"$ac_cv_hpacc_compiler" = xyes; then : $as_echo "#define NN_HAVE_HPACC 1" >>confdefs.h fi ################################################################################ # If --enable-debug is specified set appropriate compiler options. # ################################################################################ # Check whether --enable-debug was given. if test "${enable_debug+set}" = set; then : enableval=$enable_debug; fi if test "x$enable_debug" = "xyes"; then if test "x$GCC" = "xyes" -o \ "x$ac_cv_icc_compiler" = "xyes" -o \ "x$ac_cv_clang_compiler" = "xyes"; then CFLAGS="-g -O0 " elif test "x$ac_cv_sun_studio_compiler" = "xyes"; then CFLAGS="-g0 " elif test "x$ac_cv_hpacc_compiler" = "xyes"; then CFLAGS="-g +O0 " fi ORIG_CFLAGS="${CFLAGS:-none}" if test "x$ORIG_CFLAGS" != "xnone"; then CFLAGS="${CFLAGS} ${ORIG_CFLAGS}" fi $as_echo "#define NN_DEBUG 1" >>confdefs.h fi ################################################################################ # Build the documentation. # ################################################################################ # Check whether --enable-doc was given. if test "${enable_doc+set}" = set; then : enableval=$enable_doc; fi if test x"$enable_doc" = "xyes"; then : for ac_prog in asciidoc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ASCIIDOC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ASCIIDOC"; then ac_cv_prog_ASCIIDOC="$ASCIIDOC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ASCIIDOC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ASCIIDOC=$ac_cv_prog_ASCIIDOC if test -n "$ASCIIDOC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ASCIIDOC" >&5 $as_echo "$ASCIIDOC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ASCIIDOC" && break done if test x"$ASCIIDOC" = "x"; then : as_fn_error $? "Please install asciidoc to build the documentation" "$LINENO" 5 fi for ac_prog in xmlto do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_XMLTO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$XMLTO"; then ac_cv_prog_XMLTO="$XMLTO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_XMLTO="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi XMLTO=$ac_cv_prog_XMLTO if test -n "$XMLTO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XMLTO" >&5 $as_echo "$XMLTO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$XMLTO" && break done if test x"$XMLTO" = "x"; then : as_fn_error $? "Please install xmlto to build the documentation" "$LINENO" 5 fi if test ! -d "doc"; then : as_dir="doc"; as_fn_mkdir_p fi fi if test x"$ASCIIDOC" != "x" -a x"$XMLTO" != "x" ; then DOC_TRUE= DOC_FALSE='#' else DOC_TRUE='#' DOC_FALSE= fi ################################################################################ # Build nanocat # ################################################################################ # Check whether --enable-nanocat was given. if test "${enable_nanocat+set}" = set; then : enableval=$enable_nanocat; fi # Check whether --enable-symlinks was given. if test "${enable_symlinks+set}" = set; then : enableval=$enable_symlinks; fi if test x"$enable_nanocat" != "xno" -a x"$enable_symlinks" != x"no"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi fi if test x"$enable_nanocat" != "xno" ; then NANOCAT_TRUE= NANOCAT_FALSE='#' else NANOCAT_TRUE='#' NANOCAT_FALSE= fi if test x"$enable_symlinks" != "xno" ; then SYMLINKS_TRUE= SYMLINKS_FALSE='#' else SYMLINKS_TRUE='#' SYMLINKS_FALSE= fi ################################################################################ # Build tcpmuxd # ################################################################################ # Check whether --enable-tcpmuxd was given. if test "${enable_tcpmuxd+set}" = set; then : enableval=$enable_tcpmuxd; fi if test x"$enable_tcpmuxd" != "xno"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi fi if test x"$enable_tcpmuxd" != "xno" ; then TCPMUXD_TRUE= TCPMUXD_FALSE='#' else TCPMUXD_TRUE='#' TCPMUXD_FALSE= fi ################################################################################ # Check which OS we are building for. # ################################################################################ case ${host_os} in #( *linux*) : $as_echo "#define NN_HAVE_LINUX 1" >>confdefs.h ;; #( *mingw32*) : $as_echo "#define NN_HAVE_WINDOWS 1" >>confdefs.h $as_echo "#define NN_HAVE_MINGW 1" >>confdefs.h $as_echo "#define _WIN32_WINNT 0x0600" >>confdefs.h LIBS="$LIBS -lws2_32 -lMswsock" ;; #( *darwin*) : $as_echo "#define NN_HAVE_OSX 1" >>confdefs.h ;; #( *freebsd*) : $as_echo "#define NN_HAVE_FREEBSD 1" >>confdefs.h ;; #( *netbsd*) : $as_echo "#define NN_HAVE_NETBSD 1" >>confdefs.h ;; #( *openbsd*) : $as_echo "#define NN_HAVE_OPENBSD 1" >>confdefs.h ;; #( *hpux*) : $as_echo "#define NN_HAVE_HPUX 1" >>confdefs.h ;; #( *solaris*) : $as_echo "#define NN_HAVE_SOLARIS 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 $as_echo_n "checking for socket in -lsocket... " >&6; } if ${ac_cv_lib_socket_socket+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char socket (); int main () { return socket (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_socket=yes else ac_cv_lib_socket_socket=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 $as_echo "$ac_cv_lib_socket_socket" >&6; } if test "x$ac_cv_lib_socket_socket" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF LIBS="-lsocket $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 $as_echo_n "checking for gethostbyname in -lnsl... " >&6; } if ${ac_cv_lib_nsl_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); int main () { return gethostbyname (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_gethostbyname=yes else ac_cv_lib_nsl_gethostbyname=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 $as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSL 1 _ACEOF LIBS="-lnsl $LIBS" fi ;; #( *nto-qnx*) : $as_echo "#define NN_HAVE_QNX 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 $as_echo_n "checking for socket in -lsocket... " >&6; } if ${ac_cv_lib_socket_socket+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char socket (); int main () { return socket (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_socket=yes else ac_cv_lib_socket_socket=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 $as_echo "$ac_cv_lib_socket_socket" >&6; } if test "x$ac_cv_lib_socket_socket" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF LIBS="-lsocket $LIBS" fi ;; #( *) : ;; esac ################################################################################ # Feature checks. # ################################################################################ ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ax_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5 $as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_join (); int main () { return pthread_join (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ax_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5 $as_echo "$ax_pthread_ok" >&6; } if test x"$ax_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case ${host_os} in solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" ;; darwin*) ax_pthread_flags="none -pthread $ax_pthread_flags" ;; esac # Clang doesn't consider unrecognized options an error unless we specify # -Werror. We throw in some extra Clang-specific options to ensure that # this doesn't happen for GCC, which also accepts -Werror. { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler needs -Werror to reject unknown flags" >&5 $as_echo_n "checking if compiler needs -Werror to reject unknown flags... " >&6; } save_CFLAGS="$CFLAGS" ax_pthread_extra_flags="-Werror" CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo(void); int main () { foo() ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else ax_pthread_extra_flags= { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" if test x"$ax_pthread_ok" = xno; then for flag in $ax_pthread_flags; do case $flag in none) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5 $as_echo_n "checking whether pthreads work without any flags... " >&6; } ;; -*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5 $as_echo_n "checking whether pthreads work with $flag... " >&6; } PTHREAD_CFLAGS="$flag" ;; pthread-config) # Extract the first word of "pthread-config", so it can be a program name with args. set dummy pthread-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ax_pthread_config+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ax_pthread_config"; then ac_cv_prog_ax_pthread_config="$ax_pthread_config" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ax_pthread_config="yes" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_ax_pthread_config" && ac_cv_prog_ax_pthread_config="no" fi fi ax_pthread_config=$ac_cv_prog_ax_pthread_config if test -n "$ax_pthread_config"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_config" >&5 $as_echo "$ax_pthread_config" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test x"$ax_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5 $as_echo_n "checking for the pthreads library -l$flag... " >&6; } PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include static void routine(void *a) { a = 0; } static void *start_routine(void *a) { return a; } int main () { pthread_t th; pthread_attr_t attr; pthread_create(&th, 0, start_routine, 0); pthread_join(th, 0); pthread_attr_init(&attr); pthread_cleanup_push(routine, 0); pthread_cleanup_pop(0) /* ; */ ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ax_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5 $as_echo "$ax_pthread_ok" >&6; } if test "x$ax_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$ax_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5 $as_echo_n "checking for joinable pthread attribute... " >&6; } attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int attr = $attr; return attr /* ; */ ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : attr_name=$attr; break fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5 $as_echo "$attr_name" >&6; } if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then cat >>confdefs.h <<_ACEOF #define PTHREAD_CREATE_JOINABLE $attr_name _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5 $as_echo_n "checking if more special flags are required for pthreads... " >&6; } flag=no case ${host_os} in aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; osf* | hpux*) flag="-D_REENTRANT";; solaris*) if test "$GCC" = "yes"; then flag="-D_REENTRANT" else # TODO: What about Clang on Solaris? flag="-mt -D_REENTRANT" fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $flag" >&5 $as_echo "$flag" >&6; } if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_PRIO_INHERIT" >&5 $as_echo_n "checking for PTHREAD_PRIO_INHERIT... " >&6; } if ${ax_cv_PTHREAD_PRIO_INHERIT+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int i = PTHREAD_PRIO_INHERIT; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ax_cv_PTHREAD_PRIO_INHERIT=yes else ax_cv_PTHREAD_PRIO_INHERIT=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_PRIO_INHERIT" >&5 $as_echo "$ax_cv_PTHREAD_PRIO_INHERIT" >&6; } if test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"; then : $as_echo "#define HAVE_PTHREAD_PRIO_INHERIT 1" >>confdefs.h fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: compile with *_r variant if test "x$GCC" != xyes; then case $host_os in aix*) case "x/$CC" in #( x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6) : #handle absolute path differently from PATH based program lookup case "x$CC" in #( x/*) : if { test -f ${CC}_r && $as_test_x ${CC}_r; }; then : PTHREAD_CC="${CC}_r" fi ;; #( *) : for ac_prog in ${CC}_r do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PTHREAD_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PTHREAD_CC"; then ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PTHREAD_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PTHREAD_CC=$ac_cv_prog_PTHREAD_CC if test -n "$PTHREAD_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5 $as_echo "$PTHREAD_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PTHREAD_CC" && break done test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" ;; esac ;; #( *) : ;; esac ;; esac fi fi test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$ax_pthread_ok" = xyes; then LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CC="$PTHREAD_CC" : else ax_pthread_ok=no fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in netinet/in.h do : ac_fn_c_check_header_mongrel "$LINENO" "netinet/in.h" "ac_cv_header_netinet_in_h" "$ac_includes_default" if test "x$ac_cv_header_netinet_in_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NETINET_IN_H 1 _ACEOF fi done for ac_header in netdb.h do : ac_fn_c_check_header_mongrel "$LINENO" "netdb.h" "ac_cv_header_netdb_h" "$ac_includes_default" if test "x$ac_cv_header_netdb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NETDB_H 1 _ACEOF fi done for ac_header in arpa/inet.h do : ac_fn_c_check_header_mongrel "$LINENO" "arpa/inet.h" "ac_cv_header_arpa_inet_h" "$ac_includes_default" if test "x$ac_cv_header_arpa_inet_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ARPA_INET_H 1 _ACEOF fi done for ac_header in unistd.h do : ac_fn_c_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default" if test "x$ac_cv_header_unistd_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UNISTD_H 1 _ACEOF fi done for ac_header in sys/socket.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default" if test "x$ac_cv_header_sys_socket_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SOCKET_H 1 _ACEOF fi done for ac_header in sys/ioctl.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/ioctl.h" "ac_cv_header_sys_ioctl_h" "$ac_includes_default" if test "x$ac_cv_header_sys_ioctl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_IOCTL_H 1 _ACEOF fi done for ac_header in stdint.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdint.h" "ac_cv_header_stdint_h" "$ac_includes_default" if test "x$ac_cv_header_stdint_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDINT_H 1 _ACEOF $as_echo "#define NN_HAVE_STDINT 1" >>confdefs.h fi done for ac_func in eventfd do : ac_fn_c_check_func "$LINENO" "eventfd" "ac_cv_func_eventfd" if test "x$ac_cv_func_eventfd" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_EVENTFD 1 _ACEOF $as_echo "#define NN_HAVE_EVENTFD 1" >>confdefs.h fi done for ac_func in pipe do : ac_fn_c_check_func "$LINENO" "pipe" "ac_cv_func_pipe" if test "x$ac_cv_func_pipe" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PIPE 1 _ACEOF $as_echo "#define NN_HAVE_PIPE 1" >>confdefs.h fi done for ac_func in pipe2 do : ac_fn_c_check_func "$LINENO" "pipe2" "ac_cv_func_pipe2" if test "x$ac_cv_func_pipe2" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PIPE2 1 _ACEOF $as_echo "#define NN_HAVE_PIPE2 1" >>confdefs.h CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" fi done for ac_func in gethrtime do : ac_fn_c_check_func "$LINENO" "gethrtime" "ac_cv_func_gethrtime" if test "x$ac_cv_func_gethrtime" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETHRTIME 1 _ACEOF $as_echo "#define NN_HAVE_GETHRTIME 1" >>confdefs.h fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CLOCK_MONOTONIC" >&5 $as_echo_n "checking for CLOCK_MONOTONIC... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define NN_HAVE_CLOCK_MONOTONIC 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5 $as_echo_n "checking for clock_gettime in -lrt... " >&6; } if ${ac_cv_lib_rt_clock_gettime+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char clock_gettime (); int main () { return clock_gettime (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_rt_clock_gettime=yes else ac_cv_lib_rt_clock_gettime=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5 $as_echo "$ac_cv_lib_rt_clock_gettime" >&6; } if test "x$ac_cv_lib_rt_clock_gettime" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBRT 1 _ACEOF LIBS="-lrt $LIBS" fi for ac_func in clock_gettime do : ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime" if test "x$ac_cv_func_clock_gettime" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CLOCK_GETTIME 1 _ACEOF fi done for ac_func in poll do : ac_fn_c_check_func "$LINENO" "poll" "ac_cv_func_poll" if test "x$ac_cv_func_poll" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_POLL 1 _ACEOF $as_echo "#define NN_HAVE_POLL 1" >>confdefs.h fi done for ac_func in epoll_create do : ac_fn_c_check_func "$LINENO" "epoll_create" "ac_cv_func_epoll_create" if test "x$ac_cv_func_epoll_create" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_EPOLL_CREATE 1 _ACEOF $as_echo "#define NN_USE_EPOLL 1" >>confdefs.h else for ac_func in kqueue do : ac_fn_c_check_func "$LINENO" "kqueue" "ac_cv_func_kqueue" if test "x$ac_cv_func_kqueue" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_KQUEUE 1 _ACEOF $as_echo "#define NN_USE_KQUEUE 1" >>confdefs.h else $as_echo "#define NN_USE_POLL 1" >>confdefs.h fi done fi done for ac_func in accept4 do : ac_fn_c_check_func "$LINENO" "accept4" "ac_cv_func_accept4" if test "x$ac_cv_func_accept4" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ACCEPT4 1 _ACEOF $as_echo "#define NN_HAVE_ACCEPT4 1" >>confdefs.h CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getaddrinfo_a" >&5 $as_echo_n "checking for library containing getaddrinfo_a... " >&6; } if ${ac_cv_search_getaddrinfo_a+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char getaddrinfo_a (); int main () { return getaddrinfo_a (); ; return 0; } _ACEOF for ac_lib in '' anl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_getaddrinfo_a=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_getaddrinfo_a+:} false; then : break fi done if ${ac_cv_search_getaddrinfo_a+:} false; then : else ac_cv_search_getaddrinfo_a=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getaddrinfo_a" >&5 $as_echo "$ac_cv_search_getaddrinfo_a" >&6; } ac_res=$ac_cv_search_getaddrinfo_a if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define NN_HAVE_GETADDRINFO_A 1" >>confdefs.h CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" fi # Allow the use of getaddrinfo_a to be disabled. # Check whether --enable-getaddrinfo_a was given. if test "${enable_getaddrinfo_a+set}" = set; then : enableval=$enable_getaddrinfo_a; fi if test x"$enable_getaddrinfo_a" == "xno"; then : $as_echo "#define NN_DISABLE_GETADDRINFO_A 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socketpair" >&5 $as_echo_n "checking for library containing socketpair... " >&6; } if ${ac_cv_search_socketpair+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char socketpair (); int main () { return socketpair (); ; return 0; } _ACEOF for ac_lib in '' ; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_socketpair=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_socketpair+:} false; then : break fi done if ${ac_cv_search_socketpair+:} false; then : else ac_cv_search_socketpair=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socketpair" >&5 $as_echo "$ac_cv_search_socketpair" >&6; } ac_res=$ac_cv_search_socketpair if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define NN_HAVE_SOCKETPAIR 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_wait" >&5 $as_echo_n "checking for library containing sem_wait... " >&6; } if ${ac_cv_search_sem_wait+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char sem_wait (); int main () { return sem_wait (); ; return 0; } _ACEOF for ac_lib in '' rt pthread; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_sem_wait=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_sem_wait+:} false; then : break fi done if ${ac_cv_search_sem_wait+:} false; then : else ac_cv_search_sem_wait=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_sem_wait" >&5 $as_echo "$ac_cv_search_sem_wait" >&6; } ac_res=$ac_cv_search_sem_wait if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define NN_HAVE_SEMAPHORE 1" >>confdefs.h fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #include int main() { volatile uint32_t n = 0; __sync_fetch_and_add (&n, 1); __sync_fetch_and_sub (&n, 1); return 0; } ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define NN_HAVE_GCC_ATOMIC_BUILTINS 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { uint32_t value; atomic_cas_32 (&value, 0, 0); return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define NN_HAVE_ATOMIC_SOLARIS 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for msghdr.msg_control" >&5 $as_echo_n "checking for msghdr.msg_control... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct msghdr hdr; hdr.msg_control = 0; return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define NN_HAVE_MSG_CONTROL 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x"$ac_cv_func_eventfd" = xyes; then : $as_echo "#define NN_USE_EVENTFD 1" >>confdefs.h else if test x"$ac_cv_func_pipe" = xyes; then : $as_echo "#define NN_USE_PIPE 1" >>confdefs.h else if test x"$ac_cv_func_socketpair" = xyes; then : $as_echo "#define NN_USE_SOCKETPAIR 1" >>confdefs.h fi fi fi case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.2' macro_revision='1.3337' ltmain="$ac_aux_dir/ltmain.sh" # Backslashify 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' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } 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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else 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 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else 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 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } 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. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else 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; ;; mint*) # On MiNT this can take a long time and run out of memory. 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 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; 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"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$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 fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # 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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test "$GCC" != yes; then reload_cmds=false fi ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/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 # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' 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 ;; haiku*) 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])(-bit)?( [LM]SB)? 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 glibc/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 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi 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 if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # 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 \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # 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 # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # 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};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /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 lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # 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 { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && 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 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #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. */ LT_DLSYM_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_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 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 fi 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 { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 $as_echo "${with_sysroot}" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi 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 { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; 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 '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; 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 { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; 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" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } 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 ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) 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" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else 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" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } 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" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; 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 else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; 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 else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; 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 else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else 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 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF 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 # 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 for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # 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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else 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 ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" 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 fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else 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 ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" 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 fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$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);}' # 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 # 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 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* 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* ## 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... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # 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:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 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 "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-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_prog_compiler_pic='-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 lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; 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_prog_compiler_pic='-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_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-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). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-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_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # 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:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 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 "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" 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>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=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:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 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 "$_lt_compiler_boilerplate" | $SED '/^$/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_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $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* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=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:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 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 "$_lt_compiler_boilerplate" | $SED '/^$/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_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $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* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } 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 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # 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'. exclude_expsyms='_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. 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 | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = 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 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${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 whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= 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 ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, 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 install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$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)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$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... archive_expsym_cmds='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 ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${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. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='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=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$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 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='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* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='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 $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $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 ld_shlibs=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 archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=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 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$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. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=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 # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$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. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${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 hardcode_direct=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 hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi link_all_deplibs=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 export_dynamic_flag_spec='${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. always_export_symbols=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. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_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 "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$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. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_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 "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${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. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$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 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$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)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-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. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # 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. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=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. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag="$_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=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="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}" module_expsym_cmds="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}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=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*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$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 hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" 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>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test "$lt_cv_irix_exported_symbol" = yes; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$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' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='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 "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${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='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='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}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='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 hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=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 whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=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. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$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. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds 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. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # 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 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # 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; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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=`func_echo_all "$lib" | $SED '\''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 # correct to gnu/linux during the next big refactor 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,$cc_basename in yes,*) # gcc 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="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; 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 dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. 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 # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # 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' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # 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`' 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 # correct to gnu/linux during the next big refactor 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 ;; 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[23].*) 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 # correct to gnu/linux during the next big refactor 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 ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" 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=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' 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' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor 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 if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # 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;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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 # correct to gnu/linux during the next big refactor 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 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } 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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != 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, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = 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 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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; 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" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "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 /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 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; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "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 /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 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; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } 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 striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } 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" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } 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" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } 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 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" ac_config_commands="$ac_config_commands libtool" # Only expand once: # dolt, a replacement for libtool # Josh Triplett # Extract the first word of "bash", so it can be a program name with args. set dummy bash; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DOLT_BASH+:} false; then : $as_echo_n "(cached) " >&6 else case $DOLT_BASH in [\\/]* | ?:[\\/]*) ac_cv_path_DOLT_BASH="$DOLT_BASH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DOLT_BASH="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DOLT_BASH=$ac_cv_path_DOLT_BASH if test -n "$DOLT_BASH"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DOLT_BASH" >&5 $as_echo "$DOLT_BASH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if dolt supports this host" >&5 $as_echo_n "checking if dolt supports this host... " >&6; } dolt_supported=yes if test x$DOLT_BASH = x; then : dolt_supported=no fi if test x$GCC != xyes; then : dolt_supported=no fi case $host in #( *-*-linux*|*-*-freebsd*) : pic_options='-fPIC' ;; #( *-apple-darwin*) : pic_options='-fno-common' ;; #( *mingw*|*nacl*) : pic_options='' * ;; #( *) : dolt_supported=no ;; esac if test x$dolt_supported = xno; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, falling back to libtool" >&5 $as_echo "no, falling back to libtool" >&6; } LTCOMPILE='$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(COMPILE)' LTCXXCOMPILE='$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXXCOMPILE)' else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, replacing libtool" >&5 $as_echo "yes, replacing libtool" >&6; } cat <<__DOLTCOMPILE__EOF__ >doltcompile #!$DOLT_BASH __DOLTCOMPILE__EOF__ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile args=("$@") for ((arg=0; arg<${#args[@]}; arg++)) ; do if test x"${args[$arg]}" = x-o ; then objarg=$((arg+1)) break fi done if test x$objarg = x ; then echo 'Error: no -o on compiler command line' 1>&2 exit 1 fi lo="${args[$objarg]}" obj="${lo%.lo}" if test x"$lo" = x"$obj" ; then echo "Error: libtool object file name \"$lo\" does not end in .lo" 1>&2 exit 1 fi objbase="${obj##*/}" __DOLTCOMPILE__EOF__ if test x$enable_shared = xyes; then cat <<'__DOLTCOMPILE__EOF__' >>doltcompile libobjdir="${obj%$objbase}.libs" if test ! -d "$libobjdir" ; then mkdir_out="$(mkdir "$libobjdir" 2>&1)" mkdir_ret=$? if test "$mkdir_ret" -ne 0 && test ! -d "$libobjdir" ; then echo "$mkdir_out" 1>&2 exit $mkdir_ret fi fi pic_object="$libobjdir/$objbase.o" args[$objarg]="$pic_object" __DOLTCOMPILE__EOF__ cat <<__DOLTCOMPILE__EOF__ >>doltcompile "\${args[@]}" $pic_options -DPIC || exit \$? __DOLTCOMPILE__EOF__ fi if test x$enable_static = xyes; then cat <<'__DOLTCOMPILE__EOF__' >>doltcompile non_pic_object="$obj.o" args[$objarg]="$non_pic_object" __DOLTCOMPILE__EOF__ if test x$enable_shared = xyes; then cat <<'__DOLTCOMPILE__EOF__' >>doltcompile "${args[@]}" >/dev/null 2>&1 || exit $? __DOLTCOMPILE__EOF__ else cat <<'__DOLTCOMPILE__EOF__' >>doltcompile "${args[@]}" || exit $? __DOLTCOMPILE__EOF__ fi fi cat <<'__DOLTCOMPILE__EOF__' >>doltcompile { echo "# $lo - a libtool object file" echo "# Generated by doltcompile, not libtool" __DOLTCOMPILE__EOF__ if test x$enable_shared = xyes; then cat <<'__DOLTCOMPILE__EOF__' >>doltcompile echo "pic_object='.libs/${objbase}.o'" __DOLTCOMPILE__EOF__ else cat <<'__DOLTCOMPILE__EOF__' >>doltcompile echo pic_object=none __DOLTCOMPILE__EOF__ fi if test x$enable_static = xyes; then cat <<'__DOLTCOMPILE__EOF__' >>doltcompile echo "non_pic_object='${objbase}.o'" __DOLTCOMPILE__EOF__ else cat <<'__DOLTCOMPILE__EOF__' >>doltcompile echo non_pic_object=none __DOLTCOMPILE__EOF__ fi cat <<'__DOLTCOMPILE__EOF__' >>doltcompile } > "$lo" __DOLTCOMPILE__EOF__ chmod +x doltcompile LTCOMPILE='$(top_builddir)/doltcompile $(COMPILE)' LTCXXCOMPILE='$(top_builddir)/doltcompile $(CXXCOMPILE)' cat <<__DOLTLIBTOOL__EOF__ > doltlibtool #!$DOLT_BASH __DOLTLIBTOOL__EOF__ cat <<'__DOLTLIBTOOL__EOF__' >>doltlibtool top_builddir_slash="${0%%doltlibtool}" : ${top_builddir_slash:=./} args=() modeok=false tagok=false for arg in "$@"; do case "$arg" in --mode=compile) modeok=true ;; --tag=CC|--tag=CXX) tagok=true ;; --silent|--quiet) ;; *) args[${#args[@]}]="$arg" ;; esac done if $modeok && $tagok ; then . ${top_builddir_slash}doltcompile "${args[@]}" else exec ${top_builddir_slash}libtool "$@" fi __DOLTLIBTOOL__EOF__ chmod +x doltlibtool LIBTOOL='$(top_builddir)/doltlibtool' DOLT_CLEANFILES="doltlibtool doltcompile" fi # end dolt ################################################################################ # Finish the configuration phase. # ################################################################################ ac_config_files="$ac_config_files Makefile libnanomsg.pc" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that # take arguments), then branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. ac_script=' :mline /\\$/{ N s,\\\n,, b mline } t clear :clear s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g t quote s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g t quote b any :quote s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g s/\[/\\&/g s/\]/\\&/g s/\$/$$/g H :any ${ g s/^\n// s/\n/ /g p } ' DEFS=`sed -n "$ac_script" confdefs.h` ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DOC_TRUE}" && test -z "${DOC_FALSE}"; then as_fn_error $? "conditional \"DOC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${NANOCAT_TRUE}" && test -z "${NANOCAT_FALSE}"; then as_fn_error $? "conditional \"NANOCAT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${SYMLINKS_TRUE}" && test -z "${SYMLINKS_FALSE}"; then as_fn_error $? "conditional \"SYMLINKS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${TCPMUXD_TRUE}" && test -z "${TCPMUXD_FALSE}"; then as_fn_error $? "conditional \"TCPMUXD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by nanomsg $as_me 0.8-beta, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE Configuration files: $config_files Configuration commands: $config_commands Report bugs to . nanomsg home page: ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ nanomsg config.status 0.8-beta configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --he | --h | --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # 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' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # 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 PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "libnanomsg.pc") CONFIG_FILES="$CONFIG_FILES libnanomsg.pc" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" eval set X " :F $CONFIG_FILES :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # 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" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` 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_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":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. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 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. # The names of the tagged configurations supported by this script. available_tags="" # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and in which our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # 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 library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # 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. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### 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 ltmain="$ac_aux_dir/ltmain.sh" # 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 '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) if test x"$xsi_shell" = xyes; then sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ func_dirname ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_basename ()$/,/^} # func_basename /c\ func_basename ()\ {\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ func_dirname_and_basename ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ 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}"}\ } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ func_split_long_opt ()\ {\ \ func_split_long_opt_name=${1%%=*}\ \ func_split_long_opt_arg=${1#*=}\ } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ func_split_short_opt ()\ {\ \ func_split_short_opt_arg=${1#??}\ \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ func_lo2o ()\ {\ \ case ${1} in\ \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ \ *) func_lo2o_result=${1} ;;\ \ esac\ } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_xform ()$/,/^} # func_xform /c\ func_xform ()\ {\ func_xform_result=${1%.*}.lo\ } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_arith ()$/,/^} # func_arith /c\ func_arith ()\ {\ func_arith_result=$(( $* ))\ } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_len ()$/,/^} # func_len /c\ func_len ()\ {\ func_len_result=${#1}\ } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$lt_shell_append" = xyes; then sed -e '/^func_append ()$/,/^} # func_append /c\ func_append ()\ {\ eval "${1}+=\\${2}"\ } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ func_append_quoted ()\ {\ \ func_quote_for_eval "${2}"\ \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} fi mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi nanomsg-0.8-beta/AUTHORS0000664000175000017500000000477312623652600015725 0ustar00travistravis00000000000000Complete list of copyright holders to nanomsg codebase: Achille Roussel Aleksandar Fabijanic Alex Brem Andre Jonsson Andrew Starks Aram Santogidis Ark Degtiarov Bill McCroskey Boris Zentner Bruce Mitchener Bruno Bigras Chip Salzenberg David Beck Dirkjan Ochtman Dong Fang Drew Crawford Dylan Socolobsky Emeric Chevalier Emil Renner Berthing Evan Wies Gareth Roberts Garrett D'Amore Gonzalo Diethelm Gaurav Gupta Hajime Saito Harlan Lieberman-Berg Immanuel Weber Ivan Pechorin Ivo Vachkov Jack R. Dunaway Joshua Foster Julien Ammous Kaspar Schiess Kristian Lein-Mathisen Luca Barbato Manuel Mendez Mark Ellzey Martin Sustrik Matt Howlett Max Drechsler Michael John Mikko Koppanen Nick Desaulniers Nicolas Hillegeer Nir Soffer Örjan Persson Oskari Timperi Paul Colomiets Pavlo Kapyshin Remy Brunno Rob Sciuk Ryan Killea Robert G. Jakabosky Sergey Avseyev Sergey Kovalevich Sergei Nikulov Simon Strandgaard Stan Mihai Steve Atkins Steve McKay Stuart Wallace Timothee Besset Tobias Peters Victor Guerra Yonggang Luo Zoltan Boszormenyi nanomsg-0.8-beta/COPYING0000664000175000017500000000205512623652600015677 0ustar00travistravis00000000000000 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. "nanomsg" is a trademark of Martin Sustrik nanomsg-0.8-beta/compile0000755000175000017500000001533712623652611016231 0ustar00travistravis00000000000000#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-01-04.17; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free # Software Foundation, Inc. # Written by Tom Tromey . # # This program 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, or (at your option) # any later version. # # This program 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 this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l*) lib=${1#-l} found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes set x "$@" "$dir/$lib.dll.lib" break fi if test -f "$dir/$lib.lib"; then found=yes set x "$@" "$dir/$lib.lib" break fi done IFS=$save_IFS test "$found" != yes && set x "$@" "$lib.lib" shift ;; -L*) func_file_conv "${1#-L}" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: nanomsg-0.8-beta/config.guess0000755000175000017500000012743212623652611017173 0ustar00travistravis00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-02-10' # This file 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. # # This program 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 this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-gnueabi else echo ${UNAME_MACHINE}-unknown-linux-gnueabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: nanomsg-0.8-beta/config.sub0000755000175000017500000010517612623652611016637 0ustar00travistravis00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-02-10' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file 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. # # This program 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 this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i386-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: nanomsg-0.8-beta/depcomp0000755000175000017500000004755612623652611016240 0ustar00travistravis00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2011-12-04.11; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, # 2011 Free Software Foundation, Inc. # This program 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, or (at your option) # any later version. # This program 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 this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test "$stat" = 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/ \1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/ / G p }' >> "$depfile" rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: nanomsg-0.8-beta/install-sh0000755000175000017500000003325612623652611016657 0ustar00travistravis00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-01-19.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # 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 # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for `test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: nanomsg-0.8-beta/ltmain.sh0000644000175000017500000105204012623652607016471 0ustar00travistravis00000000000000 # libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # 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. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION="2.4.2 Debian-2.4.2-1ubuntu1" TIMESTAMP="" package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # 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 () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # 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 () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -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_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # 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 "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-warning|--no-warn) opt_warning=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # 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 relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS%" test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; *) func_fatal_configuration "$modename: unknown library version type \`$version_type'" ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then # Remove ${wl} instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" func_resolve_sysroot "$deplib" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 nanomsg-0.8-beta/missing0000755000175000017500000002415212623652611016245 0ustar00travistravis00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2012-01-06.13; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program 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, or (at your option) # any later version. # This program 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 this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: nanomsg-0.8-beta/abi_version.sh0000775000175000017500000000343712623652600017510 0ustar00travistravis00000000000000#!/bin/sh # Copyright (c) 2013 Luca Barbato # # 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. if [ ! -f src/nn.h ]; then echo "abi_version.sh: error: src/nn.h does not exist" 1>&2 exit 1 fi CURRENT=`egrep '^#define +NN_VERSION_CURRENT +[0-9]+$' src/nn.h` REVISION=`egrep '^#define +NN_VERSION_REVISION +[0-9]+$' src/nn.h` AGE=`egrep '^#define +NN_VERSION_AGE +[0-9]+$' src/nn.h` if [ -z "$CURRENT" -o -z "$REVISION" -o -z "$AGE" ]; then echo "abi_version.sh: error: could not extract version from src/nn.h" 1>&2 exit 1 fi CURRENT=`echo $CURRENT | awk '{ print $3 }'` REVISION=`echo $REVISION | awk '{ print $3 }'` AGE=`echo $AGE | awk '{ print $3 }'` case $1 in -libtool) printf '%s' "$CURRENT:$REVISION:$AGE" ;; *) printf '%s' "$CURRENT.$REVISION.$AGE" ;; esac nanomsg-0.8-beta/package_version.sh0000775000175000017500000000330412623652600020341 0ustar00travistravis00000000000000#!/bin/sh # Copyright (c) 2013 Luca Barbato # # 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. if [ -n "${TRAVIS_TAG}" ]; then VER="${TRAVIS_TAG}" elif [ -d .git ]; then # Retrieve the version from the last git tag. VER=`git describe --always | sed -e "s:v::"` if [ x"`git diff-index --name-only HEAD`" != x ]; then # If the sources have been changed locally, add -dirty to the version. VER="${VER}-dirty" fi elif [ -f .version ]; then # If git is not available (e.g. when building from source package) # we can extract the package version from .version file. VER=`< .version` else # The package version cannot be retrieved. VER="Unknown" fi printf '%s' "$VER" nanomsg-0.8-beta/CMakeLists.txt0000664000175000017500000001077712623652600017416 0ustar00travistravis00000000000000# # Copyright (c) 2012 Martin Sustrik All rights reserved. # Copyright (c) 2013 GoPivotal, Inc. 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. # cmake_minimum_required (VERSION 2.8) include (CheckIncludeFiles) include (CheckSymbolExists) include (CheckCSourceCompiles) project (nanomsg C) enable_testing () # Platform checks. if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") add_definitions (-DNN_HAVE_WINDOWS) add_definitions (-D_CRT_SECURE_NO_WARNINGS) if (MINGW) add_definitions (-DNN_HAVE_MINGW -DNN_HAVE_STDINT -D_WIN32_WINNT=0x0600) endif () else () message (FATAL_ERROR "ERROR: CMake build system is intended only to generate MSVC solution files.\nUse autotools build system for any other purpose." ) endif () # Build the library itself. add_subdirectory (src) # Build the tools add_executable (nanocat tools/nanocat.c tools/options.c) target_link_libraries (nanocat nanomsg) # Build unit tests. set (all_tests "") macro (add_libnanomsg_test NAME) list (APPEND all_tests ${NAME}) add_executable (${NAME} tests/${NAME}.c) target_link_libraries (${NAME} nanomsg) add_test (NAME ${NAME} COMMAND ${NAME}) set_tests_properties (${NAME} PROPERTIES TIMEOUT 30) endmacro (add_libnanomsg_test) # Transport tests. add_libnanomsg_test (inproc) add_libnanomsg_test (inproc_shutdown) add_libnanomsg_test (ipc) add_libnanomsg_test (ipc_shutdown) add_libnanomsg_test (ipc_stress) add_libnanomsg_test (tcp) add_libnanomsg_test (tcp_shutdown) add_libnanomsg_test (ws) add_libnanomsg_test (tcpmux) # Protocol tests. add_libnanomsg_test (pair) add_libnanomsg_test (pubsub) add_libnanomsg_test (reqrep) add_libnanomsg_test (pipeline) add_libnanomsg_test (survey) add_libnanomsg_test (bus) # Feature tests. add_libnanomsg_test (async_shutdown) add_libnanomsg_test (block) add_libnanomsg_test (term) add_libnanomsg_test (timeo) add_libnanomsg_test (iovec) add_libnanomsg_test (msg) add_libnanomsg_test (prio) add_libnanomsg_test (poll) add_libnanomsg_test (device) add_libnanomsg_test (device4) add_libnanomsg_test (device5) add_libnanomsg_test (emfile) add_libnanomsg_test (domain) add_libnanomsg_test (trie) add_libnanomsg_test (list) add_libnanomsg_test (hash) add_libnanomsg_test (symbol) add_libnanomsg_test (separation) add_libnanomsg_test (zerocopy) add_libnanomsg_test (shutdown) add_libnanomsg_test (cmsg) add_libnanomsg_test (bug328) # Build the performance tests. macro (add_libnanomsg_perf NAME) add_executable (${NAME} perf/${NAME}.c) target_link_libraries (${NAME} nanomsg) endmacro (add_libnanomsg_perf) add_libnanomsg_perf (inproc_lat) add_libnanomsg_perf (inproc_thr) add_libnanomsg_perf (local_lat) add_libnanomsg_perf (remote_lat) add_libnanomsg_perf (local_thr) add_libnanomsg_perf (remote_thr) # NSIS package install (FILES src/nn.h DESTINATION include/nanomsg) install (FILES src/inproc.h DESTINATION include/nanomsg) install (FILES src/ipc.h DESTINATION include/nanomsg) install (FILES src/tcp.h DESTINATION include/nanomsg) install (FILES src/ws.h DESTINATION include/nanomsg) install (FILES src/pair.h DESTINATION include/nanomsg) install (FILES src/pubsub.h DESTINATION include/nanomsg) install (FILES src/reqrep.h DESTINATION include/nanomsg) install (FILES src/pipeline.h DESTINATION include/nanomsg) install (FILES src/survey.h DESTINATION include/nanomsg) install (FILES src/bus.h DESTINATION include/nanomsg) install (TARGETS nanocat RUNTIME DESTINATION bin) set (CPACK_GENERATOR "NSIS") set (CPACK_PACKAGE_NAME "nanomsg") include (CPack) nanomsg-0.8-beta/.version0000664000175000017500000000001012623652617016327 0ustar00travistravis000000000000000.8-beta