doxygen for transport.h

doxygen for transport.h

git-svn-id: 33ed6c3feaacb64944efc691d1ae8e09b17f2bf9@1577478 13f79535-47bb-0310-9956-ffa450edef68

--- proton-c/include/proton/transport.h
+++ proton-c/include/proton/transport.h
@@ -33,7 +33,9 @@
 extern "C" {
 #endif

-/** @file
+/**
+ * @file
+ *
  * Transport API for the proton Engine.
  *
  * @defgroup transport Transport
@@ -41,68 +43,295 @@
  * @{
  */

+/**
+ * Holds the trace flags for an AMQP transport.
+ *
+ * The trace flags for an AMQP transport control what sort of
+ * information is logged by an AMQP transport. The following bits can
+ * be set:
+ *
+ * - ::PN_TRACE_OFF
+ * - ::PN_TRACE_RAW
+ * - ::PN_TRACE_FRM
+ * - ::PN_TRACE_DRV
+ *
+ */
 typedef int pn_trace_t;
+
+/**
+ * Callback for customizing logging behaviour.
+ */
 typedef void (*pn_tracer_t)(pn_transport_t *transport, const char *message);

+/**
+ * Turn logging off entirely.
+ */
 #define PN_TRACE_OFF (0)
+
+/**
+ * Log raw binary data into/out of the transport.
+ */
 #define PN_TRACE_RAW (1)
+
+/**
+ * Log frames into/out of the transport.
+ */
 #define PN_TRACE_FRM (2)
+
+/**
+ * Log driver related events, e.g. initialization, end of stream, etc.
+ */
 #define PN_TRACE_DRV (4)

-/** Factory for creating a transport.
- *
- * A transport to be used by a connection to interface with the
- * network. There can only be one connection associated with a
- * transport. See pn_transport_bind().
+/**
+ * Factory for creating a transport.
+ *
+ * A transport is used by a connection to interface with the network.
+ * There can only be one connection associated with a transport. See
+ * pn_transport_bind().
  *
  * @return pointer to new transport
  */
 PN_EXTERN pn_transport_t *pn_transport(void);

-/** Binds the transport to an AMQP connection endpoint.
+/**
+ * Free a transport object.
+ *
+ * When a transport is freed, it is automatically unbound from its
+ * associated connection.
+ *
+ * @param[in] transport a transport object or NULL
+ */
+PN_EXTERN void pn_transport_free(pn_transport_t *transport);
+
+/**
+ * Get additional error information associated with the transport.
+ *
+ * Whenever a transport operation fails (i.e. returns an error code),
+ * additional error details can be obtained using this function. The
+ * error object that is returned may also be used to clear the error
+ * condition.
+ *
+ * The pointer returned by this operation is valid until the
+ * transport object is freed.
+ *
+ * @param[in] transport the transport object
+ * @return the transport's error object
+ */
+PN_EXTERN pn_error_t *pn_transport_error(pn_transport_t *transport);
+
+/**
+ * Binds the transport to an AMQP connection.
  *
  * @return an error code, or 0 on success
  */
-
 PN_EXTERN int pn_transport_bind(pn_transport_t *transport, pn_connection_t *connection);

+/**
+ * Unbinds a transport from its AMQP connection.
+ *
+ * @return an error code, or 0 on success
+ */
 PN_EXTERN int pn_transport_unbind(pn_transport_t *transport);

-PN_EXTERN pn_error_t *pn_transport_error(pn_transport_t *transport);
-/* deprecated */
+/**
+ * Update a transports trace flags.
+ *
+ * The trace flags for a transport control what sort of information is
+ * logged. See ::pn_trace_t for more details.
+ *
+ * @param[in] transport a transport object
+ * @param[in] trace the trace flags
+ */
+PN_EXTERN void pn_transport_trace(pn_transport_t *transport, pn_trace_t trace);
+
+/**
+ * Set the tracing function used by a transport.
+ *
+ * The tracing function is called to perform logging. Overriding this
+ * function allows embedding applications to divert the engine's
+ * logging to a place of their choice.
+ *
+ * @param[in] transport a transport object
+ * @param[in] tracer the tracing function
+ */
+PN_EXTERN void pn_transport_set_tracer(pn_transport_t *transport, pn_tracer_t tracer);
+
+/**
+ * Get the tracning function used by a transport.
+ *
+ * @param[in] transport a transport object
+ * @return the tracing function used by a transport
+ */
+PN_EXTERN pn_tracer_t pn_transport_get_tracer(pn_transport_t *transport);
+
+/**
+ * Get the application context that is associated with a transport object.
+ *
+ * The application context for a transport may be set using
+ * ::pn_transport_set_context.
+ *
+ * @param[in] transport the transport whose context is to be returned.
+ * @return the application context for the transport object
+ */
+PN_EXTERN void *pn_transport_get_context(pn_transport_t *transport);
+
+/**
+ * Set a new application context for a transport object.
+ *
+ * The application context for a transport object may be retrieved using
+ * ::pn_transport_get_context.
+ *
+ * @param[in] transport the transport object
+ * @param[in] context the application context
+ */
+PN_EXTERN void pn_transport_set_context(pn_transport_t *transport, void *context);
+
+/**
+ * Log a message using a transport's logging mechanism.
+ *
+ * This can be useful in a debugging context as the log message will
+ * be prefixed with the transport's identifier.
+ *
+ * @param[in] transport a transport object
+ * @param[in] message the message to be logged
+ */
+PN_EXTERN void pn_transport_log(pn_transport_t *transport, const char *message);
+
+/**
+ * Log a printf formatted message using a transport's logging
+ * mechanism.
+ *
+ * This can be useful in a debugging context as the log message will
+ * be prefixed with the transport's identifier.
+ *
+ * @param[in] transport a transport object
+ * @param[in] fmt the printf formatted message to be logged
+ */
+PN_EXTERN void pn_transport_logf(pn_transport_t *transport, const char *fmt, ...);
+
+/**
+ * Get the maximum allowed channel for a transport.
+ *
+ * @param[in] transport a transport object
+ * @return the maximum allowed channel
+ */
+PN_EXTERN uint16_t pn_transport_get_channel_max(pn_transport_t *transport);
+
+/**
+ * Set the maximum allowed channel for a transport.
+ *
+ * @param[in] transport a transport object
+ * @param[in] channel_max the maximum allowed channel
+ */
+PN_EXTERN void pn_transport_set_channel_max(pn_transport_t *transport, uint16_t channel_max);
+
+/**
+ * Get the maximum allowed channel of a transport's remote peer.
+ *
+ * @param[in] transport a transport object
+ * @return the maximum allowed channel of the transport's remote peer
+ */
+PN_EXTERN uint16_t pn_transport_remote_channel_max(pn_transport_t *transport);
+
+/**
+ * Get the maximum frame size of a transport.
+ *
+ * @param[in] transport a transport object
+ * @return the maximum frame size of the transport object
+ */
+PN_EXTERN uint32_t pn_transport_get_max_frame(pn_transport_t *transport);
+
+/**
+ * Set the maximum frame size of a transport.
+ *
+ * @param[in] transport a transport object
+ * @param[in] size the maximum frame size for the transport object
+ */
+PN_EXTERN void pn_transport_set_max_frame(pn_transport_t *transport, uint32_t size);
+
+/**
+ * Get the maximum frame size of a transport's remote peer.
+ *
+ * @param[in] transport a transport object
+ * @return the maximum frame size of the transport's remote peer
+ */
+PN_EXTERN uint32_t pn_transport_get_remote_max_frame(pn_transport_t *transport);
+
+/**
+ * Get the idle timeout for a transport.
+ *
+ * A zero idle timeout means heartbeats are disabled.
+ *
+ * @param[in] transport a transport object
+ * @return the transport's idle timeout
+ */
+PN_EXTERN pn_millis_t pn_transport_get_idle_timeout(pn_transport_t *transport);
+
+/**
+ * Set the idle timeout for a transport.
+ *
+ * A zero idle timeout means heartbeats are disabled.
+ *
+ * @param[in] transport a transport object
+ * @param[in] timeout the idle timeout for the transport object
+ */
+PN_EXTERN void pn_transport_set_idle_timeout(pn_transport_t *transport, pn_millis_t timeout);
+
+/**
+ * Get the idle timeout for a transport's remote peer.
+ *
+ * A zero idle timeout means heartbeats are disabled.
+ *
+ * @param[in] transport a transport object
+ * @return the idle timeout for the transport's remote peer
+ */
+PN_EXTERN pn_millis_t pn_transport_get_remote_idle_timeout(pn_transport_t *transport);
+
+/**
+ * @deprecated
+ */
 PN_EXTERN ssize_t pn_transport_input(pn_transport_t *transport, const char *bytes, size_t available);
-/* deprecated */
+/**
+ * @deprecated
+ */
 PN_EXTERN ssize_t pn_transport_output(pn_transport_t *transport, char *bytes, size_t size);

-/** Report the amount of free space for input following the
- * transport's tail pointer. If the engine is in an exceptional state
- * such as encountering an error condition or reaching the end of
- * stream state, a negative value will be returned indicating the
- * condition. If an error is indicated, futher details can be obtained
- * from ::pn_transport_error. Calls to ::pn_transport_process may
- * alter the value of this pointer. See ::pn_transport_process for
- * details.
+/**
+ * Get the amount of free space for input following the transport's
+ * tail pointer.
+ *
+ * If the engine is in an exceptional state such as encountering an
+ * error condition or reaching the end of stream state, a negative
+ * value will be returned indicating the condition. If an error is
+ * indicated, futher details can be obtained from
+ * ::pn_transport_error. Calls to ::pn_transport_process may alter the
+ * value of this pointer. See ::pn_transport_process for details.
  *
  * @param[in] transport the transport
  * @return the free space in the transport, PN_EOS or error code if < 0
  */
 PN_EXTERN ssize_t pn_transport_capacity(pn_transport_t *transport);

-/** Return the transport's tail pointer. The amount of free space
- * following this pointer is reported by ::pn_transport_capacity.
- * Calls to ::pn_transport_process may alther the value of this
- * pointer. See ::pn_transport_process for details.
+/**
+ * Get the transport's tail pointer.
+ *
+ * The amount of free space following this pointer is reported by
+ * ::pn_transport_capacity. Calls to ::pn_transport_process may alther
+ * the value of this pointer. See ::pn_transport_process for details.
  *
  * @param[in] transport the transport
  * @return a pointer to the transport's input buffer, NULL if no capacity available.
  */
 PN_EXTERN char *pn_transport_tail(pn_transport_t *transport);

-/** Pushes the supplied bytes into the tail of the transport. This is
- * equivalent to copying @c size bytes afther the tail pointer and
- * then calling ::pn_transport_process with an argument of @c size. It
- * is an error to call this with a @c size larger than the capacity
- * reported by ::pn_transport_capacity.
+/**
+ * Pushes the supplied bytes into the tail of the transport.
+ *
+ * This is equivalent to copying @c size bytes afther the tail pointer
+ * and then calling ::pn_transport_process with an argument of @c
+ * size. It is an error to call this with a @c size larger than the
+ * capacity reported by ::pn_transport_capacity.
  *
  * @param[in] transport the transport
  * @param[in] src the start of the data to push into the transport
@@ -112,11 +341,14 @@
  */
 PN_EXTERN int pn_transport_push(pn_transport_t *transport, const char *src, size_t size);

-/** Process input data following the tail pointer. Calling this
- * function will cause the transport to consume @c size bytes of input
- * occupying the free space following the tail pointer. Calls to this
- * function may change the value of ::pn_transport_tail, as well as
- * the amount of free space reported by ::pn_transport_capacity.
+/**
+ * Process input data following the tail pointer.
+ *
+ * Calling this function will cause the transport to consume @c size
+ * bytes of input occupying the free space following the tail pointer.
+ * Calls to this function may change the value of ::pn_transport_tail,
+ * as well as the amount of free space reported by
+ * ::pn_transport_capacity.
  *
  * @param[in] transport the transport
  * @param[in] size the amount of data written to the transport's input buffer
@@ -124,42 +356,52 @@
  */
 PN_EXTERN int pn_transport_process(pn_transport_t *transport, size_t size);

-/** Indicate that the input has reached End Of Stream (EOS).  This
- * tells the transport that no more input will be forthcoming.
+/**
+ * Indicate that the input has reached End Of Stream (EOS).
+ *
+ * This tells the transport that no more input will be forthcoming.
  *
  * @param[in] transport the transport
  * @return 0 on success, or error code if < 0
  */
 PN_EXTERN int pn_transport_close_tail(pn_transport_t *transport);

-/** Report the number of pending output bytes following the
- * transport's head pointer. If the engine is in an exceptional state
- * such as encountering an error condition or reaching the end of
- * stream state, a negative value will be returned indicating the
- * condition. If an error is indicated, further details can be
- * obtained from ::pn_transport_error. Calls to ::pn_transport_pop may
- * alter the value of this pointer. See ::pn_transport_pop for
+/**
+ * Get the number of pending output bytes following the transport's
+ * head pointer.
+ *
+ * If the engine is in an exceptional state such as encountering an
+ * error condition or reaching the end of stream state, a negative
+ * value will be returned indicating the condition. If an error is
+ * indicated, further details can be obtained from
+ * ::pn_transport_error. Calls to ::pn_transport_pop may alter the
+ * value of this pointer. See ::pn_transport_pop for details.
+ *
+ * @param[in] transport the transport
+ * @return the number of pending output bytes, or an error code
+ */
+PN_EXTERN ssize_t pn_transport_pending(pn_transport_t *transport);
+
+/**
+ * Get the transport's head pointer.
+ *
+ * This pointer references queued output data. The
+ * ::pn_transport_pending function reports how many bytes of output
+ * data follow this pointer. Calls to ::pn_transport_pop may alter
+ * this pointer and any data it references. See ::pn_transport_pop for
  * details.
  *
  * @param[in] transport the transport
- * @return the number of pending output bytes, or an error code
- */
-PN_EXTERN ssize_t pn_transport_pending(pn_transport_t *transport);
-
-/** Return the transport's head pointer. This pointer references
- * queued output data. The ::pn_transport_pending function reports how
- * many bytes of output data follow this pointer. Calls to
- * ::pn_transport_pop may alter this pointer and any data it
- * references. See ::pn_transport_pop for details.
- *
- * @param[in] transport the transport
  * @return a pointer to the transport's output buffer, or NULL if no pending output.
  */
 PN_EXTERN const char *pn_transport_head(pn_transport_t *transport);

-/** Copies @c size bytes from the head of the transport to the @c dst
- * pointer. It is an error to call this with a value of @c size that
- * is greater than the value reported by ::pn_transport_pending.
+/**
+ * Copies @c size bytes from the head of the transport to the @c dst
+ * pointer.
+ *
+ * It is an error to call this with a value of @c size that is greater
+ * than the value reported by ::pn_transport_pending.
  *
  * @param[in] transport the transport
  * @param[out] dst the destination buffer
@@ -168,31 +410,56 @@
  */
 PN_EXTERN int pn_transport_peek(pn_transport_t *transport, char *dst, size_t size);

-/** Removes @c size bytes of output from the pending output queue
- * following the transport's head pointer. Calls to this function may
- * alter the transport's head pointer as well as the number of pending
- * bytes reported by ::pn_transport_pending.
+/**
+ * Removes @c size bytes of output from the pending output queue
+ * following the transport's head pointer.
+ *
+ * Calls to this function may alter the transport's head pointer as
+ * well as the number of pending bytes reported by
+ * ::pn_transport_pending.
  *
  * @param[in] transport the transport
  * @param[in] size the number of bytes to remove
  */
 PN_EXTERN void pn_transport_pop(pn_transport_t *transport, size_t size);

-/** Indicate that the output has closed.  This tells the transport
- * that no more output will be popped.
+/**
+ * Indicate that the output has closed.
+ *
+ * This tells the transport that no more output will be popped.
  *
  * @param[in] transport the transport
  * @return 0 on success, or error code if < 0
  */
 PN_EXTERN int pn_transport_close_head(pn_transport_t *transport);

-
-/** Process any pending transport timer events.
- *
- * This method should be called after all pending input has been processed by the
- * transport (see ::pn_transport_input), and before generating output (see
- * ::pn_transport_output).  It returns the deadline for the next pending timer event, if
- * any are present.
+/**
+ * Check if a transport has buffered data.
+ *
+ * @param[in] transport a transport object
+ * @return true if the transport has buffered data, false otherwise
+ */
+PN_EXTERN bool pn_transport_quiesced(pn_transport_t *transport);
+
+/**
+ * Check if a transport is closed.
+ *
+ * A transport is defined to be closed when both the tail and the head
+ * are closed. In other words, when both ::pn_transport_capacity() < 0
+ * and ::pn_transport_pending() < 0.
+ *
+ * @param[in] transport a transport object
+ * @return true if the transport is closed, false otherwise
+ */
+PN_EXTERN bool pn_transport_closed(pn_transport_t *transport);
+
+/**
+ * Process any pending transport timer events.
+ *
+ * This method should be called after all pending input has been
+ * processed by the transport (see ::pn_transport_input), and before
+ * generating output (see ::pn_transport_output). It returns the
+ * deadline for the next pending timer event, if any are present.
  *
  * @param[in] transport the transport to process.
  * @param[in] now the current time
@@ -202,33 +469,22 @@
  * this deadline occurs.
  */
 PN_EXTERN pn_timestamp_t pn_transport_tick(pn_transport_t *transport, pn_timestamp_t now);
-PN_EXTERN void pn_transport_trace(pn_transport_t *transport, pn_trace_t trace);
-PN_EXTERN void pn_transport_set_tracer(pn_transport_t *transport, pn_tracer_t tracer);
-PN_EXTERN pn_tracer_t pn_transport_get_tracer(pn_transport_t *transport);
-PN_EXTERN void pn_transport_set_context(pn_transport_t *transport, void *context);
-PN_EXTERN void *pn_transport_get_context(pn_transport_t *transport);
-PN_EXTERN void pn_transport_log(pn_transport_t *transport, const char *message);
-PN_EXTERN void pn_transport_logf(pn_transport_t *transport, const char *fmt, ...);
-
-PN_EXTERN uint16_t pn_transport_get_channel_max(pn_transport_t *transport);
-PN_EXTERN void pn_transport_set_channel_max(pn_transport_t *transport, uint16_t channel_max);
-PN_EXTERN uint16_t pn_transport_remote_channel_max(pn_transport_t *transport);
-
-// max frame of zero means "unlimited"
-PN_EXTERN uint32_t pn_transport_get_max_frame(pn_transport_t *transport);
-PN_EXTERN void pn_transport_set_max_frame(pn_transport_t *transport, uint32_t size);
-PN_EXTERN uint32_t pn_transport_get_remote_max_frame(pn_transport_t *transport);
-
-/* timeout of zero means "no timeout" */
-PN_EXTERN pn_millis_t pn_transport_get_idle_timeout(pn_transport_t *transport);
-PN_EXTERN void pn_transport_set_idle_timeout(pn_transport_t *transport, pn_millis_t timeout);
-PN_EXTERN pn_millis_t pn_transport_get_remote_idle_timeout(pn_transport_t *transport);
-
+
+/**
+ * Get the number of frames output by a transport.
+ *
+ * @param[in] transport a transport object
+ * @return the number of frames output by the transport
+ */
 PN_EXTERN uint64_t pn_transport_get_frames_output(const pn_transport_t *transport);
+
+/**
+ * Get the number of frames input by a transport.
+ *
+ * @param[in] transport a transport object
+ * @return the number of frames input by the transport
+ */
 PN_EXTERN uint64_t pn_transport_get_frames_input(const pn_transport_t *transport);
-PN_EXTERN bool pn_transport_quiesced(pn_transport_t *transport);
-PN_EXTERN bool pn_transport_closed(pn_transport_t *transport);
-PN_EXTERN void pn_transport_free(pn_transport_t *transport);

 #ifdef __cplusplus
 }


I make poorly thought changes a habit

I make poorly thought changes a habit

--- vector.h
+++ vector.h
@@ -12,11 +12,11 @@

 #define VECSIZ 16

-#define vec_append(inst, item)		_vec_append ((_Vector *)&(inst), &(item))
-#define vec_concat(inst, data, len)	_vec_concat ((_Vector *)&(inst), data, len * sizeof *data)
-#define vec_copy(dest, src)		_vec_copy   ((_Vector *)&(dest), (Vector *)&(src))
-#define vec_insert(inst, loc, item)	_vec_insert ((_Vector *)&(inst), loc, &(item))
-#define vec_remove(inst, loc)		_vec_remove ((_Vector *)&(inst), loc)
+#define vec_append(inst, item)		_vec_append ((Vector *)&(inst), &(item))
+#define vec_concat(inst, data, len)	_vec_concat ((Vector *)&(inst), data, len * sizeof *data)
+#define vec_copy(dest, src)		_vec_copy   ((Vector *)&(dest), (Vector *)&(src))
+#define vec_insert(inst, loc, item)	_vec_insert ((Vector *)&(inst), loc, &(item))
+#define vec_remove(inst, loc)		_vec_remove ((Vector *)&(inst), loc)

 typedef struct Vector Vector;

@@ -26,7 +26,7 @@
 extern int _vec_insert (Vector *, size_t, const void *);
 extern int _vec_remove (Vector *, size_t);

-struct _Vector {
+struct Vector {
 	void *v;
 	size_t c;
 	size_t m;


missing files are reported better

missing files are reported better

--- verify.c
+++ verify.c
@@ -23,33 +23,35 @@

     if (getEntry(h, RPMTAG_FILENAMES, &type, (void **) &fileList, &count)) {
 	for (i = 0; i < count; i++) {
-	    rpmVerifyFile(prefix, h, i, &verifyResult);
+	    if (rpmVerifyFile(prefix, h, i, &verifyResult))
+		printf("missing  %s\n", fileList[i]);
+	    else {
+		size = md5 = link = mtime = mode = ".";
+		user = group = rdev = ".";

-	    size = md5 = link = mtime = mode = ".";
-	    user = group = rdev = ".";
+		if (!verifyResult) continue;
+
+		if (verifyResult & VERIFY_MD5)
+		    md5 = "5";
+		if (verifyResult & VERIFY_FILESIZE)
+		    size = "S";
+		if (verifyResult & VERIFY_LINKTO)
+		    link = "L";
+		if (verifyResult & VERIFY_MTIME)
+		    mtime = "T";
+		if (verifyResult & VERIFY_RDEV)
+		    rdev = "D";
+		if (verifyResult & VERIFY_USER)
+		    user = "U";
+		if (verifyResult & VERIFY_GROUP)
+		    group = "G";
+		if (verifyResult & VERIFY_MODE)
+		    mode = "M";

-	    if (!verifyResult) continue;
-
-	    if (verifyResult & VERIFY_MD5)
-		md5 = "5";
-	    if (verifyResult & VERIFY_FILESIZE)
-		size = "S";
-	    if (verifyResult & VERIFY_LINKTO)
-		link = "L";
-	    if (verifyResult & VERIFY_MTIME)
-		mtime = "T";
-	    if (verifyResult & VERIFY_RDEV)
-		rdev = "D";
-	    if (verifyResult & VERIFY_USER)
-		user = "U";
-	    if (verifyResult & VERIFY_GROUP)
-		group = "G";
-	    if (verifyResult & VERIFY_MODE)
-		mode = "M";
-
-	    printf("%s%s%s%s%s%s%s%s %s\n",
-		   size, mode, md5, rdev, link, user, group, mtime,
-		   fileList[i]);
+		printf("%s%s%s%s%s%s%s%s %s\n",
+		       size, mode, md5, rdev, link, user, group, mtime,
+		       fileList[i]);
+	    }
 	}

 	free(fileList);


Added a check for including stdint.h before ustl.h and not defining __STDC macros

--- utypes.h
+++ utypes.h
@@ -13,10 +13,10 @@

 #include "config.h"
 #ifndef STDC_HEADERS
-    #error This library requires standard C and C++ headers to compile.
+    #error "This library requires standard C and C++ headers to compile."
 #endif
 #ifndef STDUNIX_HEADERS
-    #error This library compiles only on UNIX systems.
+    #error "This library compiles only on UNIX systems."
 #endif
 #define __STDC_LIMIT_MACROS	// For WCHAR_MIN and WCHAR_MAX in stdint.
 #define __STDC_CONSTANT_MACROS	// For UINT??_C macros to avoid using L and UL suffixes on constants.
@@ -25,7 +25,7 @@
 #elif HAVE_INTTYPES_H
     #include <inttypes.h>
 #else
-    #error Need standard integer types definitions, usually in stdint.h
+    #error "Need standard integer types definitions, usually in stdint.h"
 #endif
 #include <stddef.h>		// For ptrdiff_t, size_t
 #include <limits.h>
@@ -63,5 +63,7 @@
 typedef size_t		uoff_t;		///< A type for storing offsets into blocks measured by size_t.
 typedef uint32_t	hashvalue_t;	///< Value type returned by the hash functions.

+#if !defined(UINTPTR_MAX) || !defined(UINT32_C)
+    #error "If you include stdint.h before ustl.h, ensure you define __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS before doing it"
 #endif
-
+#endif


Fix off-by ones in UTF-8 parsing in terminal

- 11100000 (224) was misinterpreted as 2-byte sequence, whereas it defines a 3-byte
- 11110000 (240) was misinterpreted as 3-byte sequence, whereas it defines a 4-byte

Makes it possible to type characters from the Supplementary Multilingual Plane such as 𐎒 and 𝄐.


removed debugging printf

removed debugging printf

--- v/unix.c
+++ v/unix.c
@@ -203,7 +203,6 @@
   u2_Host.unx_u.sylo[slot].pax_c = strdup(nod_u->pax_c);
 #endif

-  uL(fprintf(uH, "fs: %s in %s\n", pax_c, nod_u->pax_c));
   {
     while ( nod_u ) {
       nod_u->dry = u2_no;


Add !find-file

Add !find-file

This will be used to locate the main module.

--- vm/eva.c
+++ vm/eva.c
@@ -334,6 +334,73 @@
 	return Nothing;
 }

+Error find_file_(Stack *S, Stack *scope_arr)
+{
+	require(1);
+	V file_name = popS();
+	if (getType(file_name) != T_STR)
+	{
+		clear_ref(file_name);
+		return TypeError;
+	}
+	NewString *fn = toNewString(file_name);
+	int l = fn->size;
+	char *f_name = fn->text;
+	struct stat deja_file;
+	struct stat vu_file;
+	int deja_exists;
+	int vu_exists;
+	if (l > 5 && !memcmp(f_name + l - 5, ".deja", 5))
+	{
+		// .deja
+		// check if we need to invoke compiler
+		deja_exists = stat(f_name, &deja_file) == 0;
+
+		utf8 text;
+		V compiled_name = empty_string_to_value(l - 2, &text);
+		memcpy(text, f_name, l - 4);
+		text[l - 4] = 'v';
+		text[l - 3] = 'u';
+
+		vu_exists = stat(text, &vu_file) == 0;
+
+		if (!deja_exists && !vu_exists)
+		{
+			clear_ref(file_name);
+			set_error_msg_ref(malloc(21 + l));
+			sprintf(error_msg, "could not find file %*s", l, f_name);
+			return IllegalFile;
+		}
+
+		pushS(compiled_name);
+
+		if (!vu_exists || difftime(deja_file.st_mtime, vu_file.st_mtime) > 0)
+		{
+			pushS(file_name);
+		}
+		else
+		{
+			pushS(add_ref(v_false));
+		}
+	}
+	else
+	{
+		// .vu
+		// never invoke compiler
+		vu_exists = stat(f_name, &vu_file) == 0;
+		if (!vu_exists)
+		{
+			clear_ref(file_name);
+			set_error_msg_ref(malloc(21 + l));
+			sprintf(error_msg, "could not find file %*s", l, f_name);
+			return IllegalFile;
+		}
+		pushS(file_name);
+		pushS(add_ref(v_false));
+	}
+	return Nothing;
+}
+
 CFunc eva[] = {
 	{"encode", encode},
 	{"decode", decode},
@@ -342,6 +409,7 @@
 	{"close", close_file},
 	{"write-fragment", write_fragment},
 	{"find-module", find_module},
+	{"find-file", find_file_},
 	{"run-file", run_file},
 	{NULL, NULL}
 };


Adds "not" function

Adds "not" function

--- vm/lib.c
+++ vm/lib.c
@@ -324,6 +324,16 @@
 		}
 	}
 	push(S, int_to_value(t));
+	clear_ref(v1);
+	clear_ref(v2);
+	return Nothing;
+}
+
+Error not(Header* h, Stack* S, Stack* scope_arr)
+{
+	V v = pop(S);
+	push(S, int_to_value(truthy(v) ? 0 : 1));
+	clear_ref(v);
 	return Nothing;
 }

@@ -349,6 +359,7 @@
 	{"<", lt},
 	{">", gt},
 	{"=", eq},
+	{"not", not},
 	{NULL, NULL}
 };


walker.c: use ref transaction for ref updates

Switch to using ref transactions in walker_fetch(). As part of the refactoring
to use ref transactions we also fix a potential memory leak where in the
original code if write_ref_sha1() would fail we would end up returning from
the function without free()ing the msg string.

Note that this function is only called when fetching from a remote HTTP
repository onto the local (most of the time single-user) repository which
likely means that the type of collisions that the previous locking would
protect against and cause the fetch to fail for are even more rare.

Signed-off-by: Ronnie Sahlberg <2cb6c6c4ccf58d41468189c2307f7a4ebf120324@google.com>
Reviewed-by: Michael Haggerty <c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu>
Signed-off-by: Jonathan Nieder <b57189c5f2fd5b3daf3350a77fde90def1080fa5@gmail.com>
Signed-off-by: Junio C Hamano <a6723cc3f76163bf7adb636a73ac3b0ceb3e6b9b@pobox.com>

--- walker.c
+++ walker.c
@@ -251,40 +251,40 @@
 int walker_fetch(struct walker *walker, int targets, char **target,
 		 const char **write_ref, const char *write_ref_log_details)
 {
-	struct ref_lock **lock = xcalloc(targets, sizeof(struct ref_lock *));
+	struct strbuf refname = STRBUF_INIT;
+	struct strbuf err = STRBUF_INIT;
+	struct ref_transaction *transaction = NULL;
 	unsigned char *sha1 = xmalloc(targets * 20);
-	char *msg;
-	int ret;
-	int i;
+	char *msg = NULL;
+	int i, ret = -1;

 	save_commit_buffer = 0;

-	for (i = 0; i < targets; i++) {
-		if (!write_ref || !write_ref[i])
-			continue;
-
-		lock[i] = lock_ref_sha1(write_ref[i], NULL);
-		if (!lock[i]) {
-			error("Can't lock ref %s", write_ref[i]);
-			goto unlock_and_fail;
-		}
-	}
-
+	if (write_ref) {
+		transaction = ref_transaction_begin(&err);
+		if (!transaction) {
+			error("%s", err.buf);
+			goto done;
+		}
+	}
 	if (!walker->get_recover)
 		for_each_ref(mark_complete, NULL);

 	for (i = 0; i < targets; i++) {
 		if (interpret_target(walker, target[i], &sha1[20 * i])) {
 			error("Could not interpret response from server '%s' as something to pull", target[i]);
-			goto unlock_and_fail;
+			goto done;
 		}
 		if (process(walker, lookup_unknown_object(&sha1[20 * i])))
-			goto unlock_and_fail;
+			goto done;
 	}

 	if (loop(walker))
-		goto unlock_and_fail;
-
+		goto done;
+	if (!write_ref) {
+		ret = 0;
+		goto done;
+	}
 	if (write_ref_log_details) {
 		msg = xmalloc(strlen(write_ref_log_details) + 12);
 		sprintf(msg, "fetch from %s", write_ref_log_details);
@@ -292,23 +292,33 @@
 		msg = NULL;
 	}
 	for (i = 0; i < targets; i++) {
-		if (!write_ref || !write_ref[i])
+		if (!write_ref[i])
 			continue;
-		ret = write_ref_sha1(lock[i], &sha1[20 * i], msg ? msg : "fetch (unknown)");
-		lock[i] = NULL;
-		if (ret)
-			goto unlock_and_fail;
-	}
+		strbuf_reset(&refname);
+		strbuf_addf(&refname, "refs/%s", write_ref[i]);
+		if (ref_transaction_update(transaction, refname.buf,
+					   &sha1[20 * i], NULL, 0, 0,
+					   &err)) {
+			error("%s", err.buf);
+			goto done;
+		}
+	}
+	if (ref_transaction_commit(transaction,
+				   msg ? msg : "fetch (unknown)",
+				   &err)) {
+		error("%s", err.buf);
+		goto done;
+	}
+
+	ret = 0;
+
+done:
+	ref_transaction_free(transaction);
 	free(msg);
-
-	return 0;
-
-unlock_and_fail:
-	for (i = 0; i < targets; i++)
-		if (lock[i])
-			unlock_ref(lock[i]);
-
-	return -1;
+	free(sha1);
+	strbuf_release(&err);
+	strbuf_release(&refname);
+	return ret;
 }

 void walker_free(struct walker *walker)


storage: Convert qemu-img -help parsing to virCommand

--- src/storage/storage_backend.c
+++ src/storage/storage_backend.c
@@ -602,28 +602,19 @@

 static int virStorageBackendQEMUImgBackingFormat(const char *qemuimg)
 {
-    const char *const qemuarg[] = { qemuimg, "-h", NULL };
-    const char *const qemuenv[] = { "LC_ALL=C", NULL };
-    pid_t child = 0;
-    int status;
-    int newstdout = -1;
     char *help = NULL;
-    enum { MAX_HELP_OUTPUT_SIZE = 1024*8 };
     char *start;
     char *end;
     char *tmp;
     int ret = -1;
-
-    if (virExec(qemuarg, qemuenv, NULL,
-                &child, -1, &newstdout, NULL, VIR_EXEC_CLEAR_CAPS) < 0)
-        goto cleanup;
-
-    if (virFileReadLimFD(newstdout, MAX_HELP_OUTPUT_SIZE, &help) < 0) {
-        virReportSystemError(errno,
-                             _("Unable to read '%s -h' output"),
-                             qemuimg);
-        goto cleanup;
-    }
+    virCommandPtr cmd = virCommandNewArgList(qemuimg, "-h", NULL);
+
+    virCommandAddEnvString(cmd, "LC_ALL=C");
+    virCommandSetOutputBuffer(cmd, &help);
+    virCommandClearCaps(cmd);
+
+    if (virCommandRun(cmd, NULL) < 0)
+        goto cleanup;

     start = strstr(help, " create ");
     end = strstr(start, "\n");
@@ -636,18 +627,8 @@
         ret = QEMU_IMG_BACKING_FORMAT_NONE;

 cleanup:
+    virCommandFree(cmd);
     VIR_FREE(help);
-    VIR_FORCE_CLOSE(newstdout);
-    if (child) {
-        while (waitpid(child, &status, 0) == -1 && errno == EINTR);
-        if (status) {
-            tmp = virCommandTranslateStatus(status);
-            VIR_WARN("Unexpected status, qemu probably failed: %s",
-                     NULLSTR(tmp));
-            VIR_FREE(tmp);
-        }
-    }
-
     return ret;
 }


size_type changed to signed (unsigned is bad, mmkay?)

--- vector.h
+++ vector.h
@@ -4,14 +4,19 @@
 #include "rdestl/algorithm.h"
 #include "rdestl/allocator.h"
 #include "rdestl/rdestl.h"
+
+// @TODO Wont work on 64-bit!
+// 4267 -- conversion from size_t to int.
+#pragma warning(push)
+#pragma warning(disable: 4267)

 namespace rde
 {
 //=============================================================================
 struct base_vector
 {
-	typedef size_t				size_type;
-	static const size_type		npos = size_type(-1);
+	typedef int				size_type;
+	static const size_type	npos = size_type(-1);
 };

 //=============================================================================
@@ -34,7 +39,8 @@
 		if (canShrink || newCapacity > m_capacity)
 		{
 			T* newBegin = static_cast<T*>(m_allocator.allocate(newCapacity * sizeof(T)));
-			const base_vector::size_type currSize(m_end - m_begin);
+			const size_t s(m_end - m_begin);
+			const base_vector::size_type currSize(s);
 			const base_vector::size_type newSize = currSize < newCapacity ? currSize : newCapacity;
 			// Copy old data if needed.
 			if (m_begin)
@@ -54,7 +60,7 @@
 	{
 		RDE_ASSERT(newCapacity > m_capacity);
 		T* newBegin = static_cast<T*>(m_allocator.allocate(newCapacity * sizeof(T)));
-		const base_vector::size_type currSize(m_end - m_begin);
+		const base_vector::size_type currSize((size_t)(m_end - m_begin));
 		if (m_begin)
 			destroy(m_begin, currSize);
 		m_begin = newBegin;
@@ -127,8 +133,9 @@
 			TStorage::destroy(m_begin, size());
 	}

-	// @note: allocator is not copied!
-	// @note: will not perform default constructor for newly created objects.
+	// @note:	allocator is not copied!
+	// @note:	will not perform default constructor for newly created objects,
+	//			just initialize with copy ctor of elements of rhs.
 	vector& operator=(const vector& rhs)
 	{
 		const size_type newSize = rhs.size();
@@ -151,16 +158,26 @@
 	iterator end()					{ return m_end; }
 	const_iterator end() const		{ return m_end; }
 	size_type size() const			{ return size_type(m_end - m_begin); }
-	size_type empty() const			{ return m_begin == m_end; }
+	bool empty() const				{ return m_begin == m_end; }
 	size_type capacity() const		{ return m_capacity; }

 	T* data()				{ return empty() ? 0 : m_begin; }
 	const T* data() const	{ return empty() ? 0 : m_begin; }

-	const T& front() const
+	T& front()
 	{
 		RDE_ASSERT(!empty());
 		return *begin();
+	}
+	const T& front() const
+	{
+		RDE_ASSERT(!empty());
+		return *begin();
+	}
+	T& back()
+	{
+		RDE_ASSERT(!empty());
+		return *(end() - 1);
 	}
 	const T& back() const
 	{
@@ -265,7 +282,7 @@
 	{
 		RDE_ASSERT(validate_iterator(it));
 		RDE_ASSERT(invariant());
-		const size_type index = it - m_begin;
+		const size_type index = (size_t)(it - m_begin);
 		const size_type prevSize = size();
 		RDE_ASSERT(index <= prevSize);
 		const size_type toMove = prevSize - index;
@@ -416,6 +433,7 @@
 	}
 };

+#pragma warning(pop)

 } // namespace rde


Modified comments

Modified comments


Activate low-volume optional logging during regression test runs.

Elaborated from an idea by Andres Freund.

--- src/test/regress/pg_regress.c
+++ src/test/regress/pg_regress.c
@@ -2456,12 +2456,12 @@
 		}

 		/*
-		 * Adjust the default postgresql.conf as needed for regression
-		 * testing. The user can specify a file to be appended; in any case we
-		 * set max_prepared_transactions to enable testing of prepared xacts.
-		 * (Note: to reduce the probability of unexpected shmmax failures,
-		 * don't set max_prepared_transactions any higher than actually needed
-		 * by the prepared_xacts regression test.)
+		 * Adjust the default postgresql.conf for regression testing. The user
+		 * can specify a file to be appended; in any case we expand logging
+		 * and set max_prepared_transactions to enable testing of prepared
+		 * xacts.  (Note: to reduce the probability of unexpected shmmax
+		 * failures, don't set max_prepared_transactions any higher than
+		 * actually needed by the prepared_xacts regression test.)
 		 */
 		snprintf(buf, sizeof(buf), "%s/data/postgresql.conf", temp_install);
 		pg_conf = fopen(buf, "a");
@@ -2471,6 +2471,10 @@
 			exit(2);
 		}
 		fputs("\n# Configuration added by pg_regress\n\n", pg_conf);
+		fputs("log_autovacuum_min_duration = 0\n", pg_conf);
+		fputs("log_checkpoints = on\n", pg_conf);
+		fputs("log_lock_waits = on\n", pg_conf);
+		fputs("log_temp_files = 128kB\n", pg_conf);
 		fputs("max_prepared_transactions = 2\n", pg_conf);

 		if (temp_config != NULL)


Fixed optimization errors on Windows.

Fixed optimization errors on Windows.

--- win/dw.c
+++ win/dw.c
@@ -2691,13 +2691,17 @@

 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y)
 {
+	HWND handle1, handle2;
+	Box *tmp;
+
 	if(type == DW_HORZ)
 	{
 		int newx = x;
 		float ratio = (float)percent/(float)100.0;
-		HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
-		HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright");
-		Box *tmp = (Box *)GetWindowLongPtr(handle1, GWLP_USERDATA);
+
+		handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
+		handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright");
+		tmp = (Box *)GetWindowLongPtr(handle1, GWLP_USERDATA);

 		newx = (int)((float)newx * ratio) - (SPLITBAR_WIDTH/2);

@@ -2720,9 +2724,10 @@
 	{
 		int newy = y;
 		float ratio = (float)(100.0-percent)/(float)100.0;
-		HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright");
-		HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
-		Box *tmp = (Box *)GetWindowLongPtr(handle1, GWLP_USERDATA);
+
+		handle1 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright");
+		handle2 = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
+		tmp = (Box *)GetWindowLongPtr(handle1, GWLP_USERDATA);

 		newy = (int)((float)newy * ratio) - (SPLITBAR_WIDTH/2);


Changed shift assign token names

Changed shift assign token names

RIGHT_ASSIGN and LEFT_ASSIGN were not very clear for >>= and <<=, so it is a
better name RSHIFT_ASSIGN and LSHIFT_ASSIGN, where it is implicit the
assignment meaning.

--- tokens.h
+++ tokens.h
@@ -25,7 +25,7 @@
   IDENTIFIER = 128, CONSTANT, STRING_LITERAL, SIZEOF,
 	PTR_OP, INC_OP, DEC_OP, LEFT_OP, RIGHT_OP, LE_OP, GE_OP, EQ_OP, NE_OP,
 	AND_OP, OR_OP, MUL_ASSIGN, DIV_ASSIGN, MOD_ASSIGN, ADD_ASSIGN,
-	SUB_ASSIGN, LEFT_ASSIGN, RIGHT_ASSIGN, AND_ASSIGN,
+	SUB_ASSIGN, LSHIFT_ASSIGN, RSHIFT_ASSIGN, AND_ASSIGN,
 	XOR_ASSIGN, OR_ASSIGN, TYPE_NAME,
 	ELLIPSIS,
 	CASE, DEFAULT, IF, ELSE, SWITCH, WHILE, DO, FOR, GOTO,


Only set the transparent color on bitmaps with 8 bits per pixel.. otherwise you get a black square.

--- win/dw.c
+++ win/dw.c
@@ -8965,7 +8965,7 @@
  */
 void API dw_pixmap_set_transparent_color( HPIXMAP pixmap, ULONG color )
 {
-   if ( pixmap )
+   if ( pixmap && pixmap->depth == 8)
    {
       pixmap->transcolor = _internal_color(color);
    }


accumulator load and set bit conditions bug fix


Fix for dw_notebook_page_new() changing active page incorrectly on Windows.

--- win/dw.c
+++ win/dw.c
@@ -6316,11 +6316,6 @@
             array[z]->item.iImage = -1;
             array[z]->item.pszText = "";
             TabCtrl_InsertItem(handle, z, &(array[z]->item));
-
-            if(oldpage > -1 && array[oldpage])
-               SetParent(array[oldpage]->hwnd, DW_HWND_OBJECT);
-
-            TabCtrl_SetCurSel(handle, z);
             return refid;
          }
       }


Fix return statement issue.

Fix return statement issue.

--- walker.c
+++ walker.c
@@ -274,11 +274,12 @@
 		}
 		wasReturn = 0;
 		result = ctr_cwlk_expr(node, &wasReturn);
-		if ( wasReturn == 0 ) {
-			/* Perform garbage collection cycle */
-			if ( ( ctr_gc_mode & 1 ) && ctr_gc_alloc > ( ctr_gc_memlimit * 0.8 ) ) {
-				ctr_gc_internal_collect();
-			}
+		if ( wasReturn ) {
+			break;
+		}
+		/* Perform garbage collection cycle */
+		if ( ( ctr_gc_mode & 1 ) && ctr_gc_alloc > ( ctr_gc_memlimit * 0.8 ) ) {
+			ctr_gc_internal_collect();
 		}
 		if (!li->next) break;
 		li = li->next;


Handle remapped windows in manage_window

--- window.c
+++ window.c
@@ -48,6 +48,17 @@
     if (override_redirect || locate_window(win, &loc))
         return;

+    bool fresh = true;
+    uint32_t idx;
+    if (xcb_ewmh_get_wm_desktop_reply(ewmh, xcb_ewmh_get_wm_desktop(ewmh, win), &idx, NULL) == 1) {
+        coordinates_t loc;
+        if (ewmh_locate_desktop(idx, &loc)) {
+            m = loc.monitor;
+            d = loc.desktop;
+        }
+        fresh = false;
+    }
+
     bool floating = false, fullscreen = false, locked = false, sticky = false, follow = false, transient = false, takes_focus = true, frame = false, private = false, manage = true;
     handle_rules(win, &m, &d, &floating, &fullscreen, &locked, &sticky, &follow, &transient, &takes_focus, &frame, &private, &manage);

@@ -61,8 +72,10 @@

     client_t *c = make_client(win);
     update_floating_rectangle(c);
-    c->floating_rectangle.x += m->rectangle.x;
-    c->floating_rectangle.y += m->rectangle.y;
+    if (fresh) {
+        c->floating_rectangle.x += m->rectangle.x;
+        c->floating_rectangle.y += m->rectangle.y;
+    }
     c->frame = frame;

     xcb_icccm_get_wm_class_reply_t reply;


51.0 for wind is a missing value

51.0 for wind is a missing value

--- ws2300.c
+++ ws2300.c
@@ -346,13 +346,17 @@
 			  double wind = (((data[3]&0x1f)<<4) + ((data[4]&0xf0)>>4) ) / 10.0;
 			  int windDir = (data[4] & 0x0f);
 			  if ( data[1] & 0x80) {
-			      addSample( &averageWindSpeed, wind);
-			      addSample( &windDirection, windDir);
-			      currentWindSpeed = wind;
-			      currentWindDirection = windDir;
+			      if ( wind != 51.0) {
+				  addSample( &gustWindSpeed, wind);
+				  currentGustSpeed = wind;
+			      }
 			  } else {
-			      addSample( &gustWindSpeed, wind);
-			      currentGustSpeed = wind;
+			      if ( wind != 51.0) {
+				  addSample( &averageWindSpeed, wind);
+				  addSample( &windDirection, windDir);
+				  currentWindSpeed = wind;
+				  currentWindDirection = windDir;
+			      }
 			  }
 		      }
 		    break;


db: Avoid double setting of global conn variable

In db_conn() we would initialise the global MYSQL conn variable and then
return it also in a call like

    conn = db_conn();

thus setting it again, while harmless, it's unnecessary. So instead use
a local MYSQL pointer variable to set things up and return that.

Signed-off-by: Andrew Clayton <02e0a999c50b1f88df7a8f5a04e1b76b35ea6a88@digital-domain.net>

--- www/db.c
+++ www/db.c
@@ -34,6 +34,7 @@
  */
 MYSQL *db_conn(void)
 {
+	MYSQL *mysql;
 	MYSQL *ret;
 	char *db_name;

@@ -49,25 +50,25 @@
 		db_name = strdup(cfg->db_name);
 	}

-	conn = mysql_init(NULL);
-	ret = mysql_real_connect(conn, cfg->db_host, cfg->db_user, cfg->db_pass,
-				 db_name, cfg->db_port_num,
+	mysql = mysql_init(NULL);
+	ret = mysql_real_connect(mysql, cfg->db_host, cfg->db_user,
+				 cfg->db_pass, db_name, cfg->db_port_num,
 				 cfg->db_socket_name, cfg->db_flags);
 	if (!ret) {
 		d_fprintf(error_log,
 			  "Failed to connect to database. Error: %s\n",
-			  mysql_error(conn));
-		switch (mysql_errno(conn)) {
+			  mysql_error(mysql));
+		switch (mysql_errno(mysql)) {
 		case ER_BAD_DB_ERROR:	/* unknown database */
 			send_page("templates/invalid.tmpl");
 			break;
 		}
-		mysql_close(conn);
-		conn = NULL;
+		mysql_close(mysql);
+		mysql = NULL;
 	}
 	free(db_name);

-	return conn;
+	return mysql;
 }

 /*


php5 cli zts dtor fix

php5 cli zts dtor fix

git-svn-id: 88e1a00e4eab3b0bb0c09889526309a3e2f5bd8a@25 c26eb9a1-5813-0410-bd6c-c2e55f420ca7

--- xcache.c
+++ xcache.c
@@ -1862,7 +1862,9 @@
 		pefree(xc_coredump_dir, 1);
 		xc_coredump_dir = NULL;
 	}
-#ifndef ZTS
+#ifdef ZTS
+	ts_free_id(xcache_globals_id);
+#else
 	xc_shutdown_globals(&xcache_globals TSRMLS_CC);
 #endif


remove speed

remove speed

--- ttygif.c
+++ ttygif.c
@@ -44,7 +44,7 @@

 typedef int    (*ReadFunc)    (FILE *fp, Header *h, char **buf);
 typedef void   (*WriteFunc)   (char *buf, int len);
-typedef void   (*ProcessFunc) (FILE *fp, double speed, ReadFunc read_func);
+typedef void   (*ProcessFunc) (FILE *fp, ReadFunc read_func);

 struct timeval
 timeval_diff (struct timeval tv1, struct timeval tv2)
@@ -112,10 +112,10 @@
 }

 void
-ttyplay (FILE *fp, double speed, ReadFunc read_func, WriteFunc write_func)
+ttyplay (FILE *fp, ReadFunc read_func, WriteFunc write_func)
 {
     int step = 0;
-    char step_name [50];
+    char cmd [50];
     char* wid = getenv("WINDOWID");

     setbuf(stdout, NULL);
@@ -129,8 +129,11 @@
             break;
         }

-        sprintf(step_name, "import -window %s %05d.gif", wid, step);
-        system(step_name);
+        sprintf(cmd, "import -window %s %05d.gif", wid, step);
+        if (system(cmd) != 0) {
+            printf("error invoking import command (is ImageMagick installed?)");
+            break;
+        }
         step++;

         write_func(buf, h.len);
@@ -138,9 +141,9 @@
     }
 }

-void ttyplayback (FILE *fp, double speed, ReadFunc read_func)
+void ttyplayback (FILE *fp, ReadFunc read_func)
 {
-    ttyplay(fp, speed, ttyread, ttywrite);
+    ttyplay(fp, ttyread, ttywrite);
 }

 void
@@ -166,30 +169,12 @@
 int
 main (int argc, char **argv)
 {
-    double speed = 1.0;
     ReadFunc read_func  = ttyread;
     ProcessFunc process = ttyplayback;
     FILE *input = NULL;
     struct termios old, new;

     set_progname(argv[0]);
-    while (1) {
-        int ch = getopt(argc, argv, "s:np");
-        if (ch == EOF) {
-            break;
-        }
-        switch (ch) {
-        case 's':
-            if (optarg == NULL) {
-                perror("-s option requires an argument");
-                exit(EXIT_FAILURE);
-            }
-            sscanf(optarg, "%lf", &speed);
-            break;
-        default:
-            usage();
-        }
-    }

     if (optind < argc) {
         input = efopen(argv[optind], "r");
@@ -203,7 +188,7 @@
     new.c_lflag &= ~(ICANON | ECHO | ECHONL); /* unbuffered, no echo */
     tcsetattr(0, TCSANOW, &new); /* Make it current */

-    process(input, speed, read_func);
+    process(input, read_func);
     tcsetattr(0, TCSANOW, &old);  /* Return terminal state */

     return 0;


Create wk1_n2.c

Create wk1_n2.c

error: pathspec 'wk1_n2.c' did not match any file(s) known to git

--- wk1_n2.c
+++ wk1_n2.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main () {
+  int first,second;
+  printf ("Enter two integers: ");
+  scanf("%d %d", &first, &second);
+  printf("The user entered %d and %d", first, second);
+return 0;
+}


git-svn-id: https://semicomplete.googlecode.com/svn/xdotool@1881 66067f73-fe4c-0410-82e9-b9c6d0c95a22

--- wmspec.c
+++ wmspec.c
@@ -1,89 +0,0 @@
-
-#include <X11/Xlib.h>
-#include <X11/Xresource.h>
-#include <X11/Xutil.h>
-#include <X11/extensions/XTest.h>
-#include <X11/Xatom.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-unsigned char * get_window_property(Display *xdpy, Window window, Atom atom,
-                                    long *nitems, Atom *type, int *size) {
-  /* slightly modified version from xprop.c from Xorg */
-  Atom actual_type;
-  int actual_format;
-  unsigned long _nitems;
-  unsigned long nbytes;
-  unsigned long bytes_after; /* unused */
-  unsigned char *prop;
-  int status;
-
-  status = XGetWindowProperty(xdpy, window, atom, 0, (~0L),
-                              False, AnyPropertyType, &actual_type,
-                              &actual_format, &_nitems, &bytes_after,
-                              &prop);
-  if (status == BadWindow) {
-    fprintf(stderr, "window id # 0x%lx does not exists!", window);
-    return NULL;
-  } if (status != Success) {
-    fprintf(stderr, "XGetWindowProperty failed!");
-    return NULL;
-  }
-
-  if (actual_format == 32)
-    nbytes = sizeof(long);
-  else if (actual_format == 16)
-    nbytes = sizeof(short);
-  else if (actual_format == 8)
-    nbytes = 1;
-  else if (actual_format == 0)
-    nbytes = 0;
-
-  *nitems = _nitems;
-  *type = actual_type;
-  *size = actual_format;
-  return prop;
-}
-
-int *ewmh__NET_SUPPORTED(Display *xdpy, Window wid, Atom **atoms, long *nitems) {
-  unsigned char *data;
-  long _nitems;
-  Atom type;
-  int size;
-  data = get_window_property(xdpy, wid,
-                             XInternAtom(xdpy, "_NET_SUPPORTED", False),
-                             &_nitems, &type, &size);
-  if (nitems <= 0)
-    return NULL;
-
-  *atoms = (Atom *)data;
-  *nitems = _nitems;
-}
-
-int main(int argc, char **argv) {
-  Display *xdpy;
-  Window root;
-  long length;
-  Atom type;
-  int size;
-  unsigned char *data;
-
-  xdpy = XOpenDisplay(NULL);
-  root = RootWindow(xdpy, 0);
-  data = get_window_property(xdpy, root,
-                             XInternAtom(xdpy, argv[1], False),
-                             &length, &type, &size);
-  printf("Length: %ld\n", length);
-  printf("Type: %ld\n", type);
-  printf("Size: %d\n", size);
-
-  Atom *supported;
-  long nitems;
-  ewmh__NET_SUPPORTED(xdpy, root, &supported, &nitems);
-
-  XFree(data);
-
-  return 0;
-}
-


fix a bug in yuv_cvt_frame()

fix a bug in yuv_cvt_frame()

--- yuvcvt.c
+++ yuvcvt.c
@@ -596,6 +596,7 @@
         yuv_seq_t *ptmp=psrc; psrc=pdst; pdst=ptmp; \
     } while(0)

+    SWAP_SRC_DST();
     /**
      *  b10-untile/unpack, b8-untile
      */


fix unmapping problem

fix unmapping problem

--- ws2811.c
+++ ws2811.c
@@ -116,6 +116,24 @@
 }

 /**
+ * Unmap a physical address and length from virtual memory.
+ *
+ * @param    addr  Virtual address pointer of device registers.
+ * @param    len   Length of mapped region.
+ *
+ * @returns  None
+ */
+static void unmap_device(volatile void *addr, const uint32_t len)
+{
+    uint32_t virt = (uint32_t)addr;
+    uint32_t start_page_addr = virt & PAGE_MASK;
+    uint32_t end_page_addr = (virt + len) & PAGE_MASK;
+    uint32_t pages = end_page_addr - start_page_addr + 1;
+
+    munmap((void *)addr, PAGE_SIZE * pages);
+}
+
+/**
  * Map all devices into userspace memory.
  *
  * @param    ws2811  ws2811 instance pointer.
@@ -173,22 +191,22 @@

     if (device->dma)
     {
-        unmapmem((void *)device->dma, sizeof(dma_t));
+        unmap_device(device->dma, sizeof(dma_t));
     }

     if (device->pwm)
     {
-        unmapmem((void *)device->pwm, sizeof(pwm_t));
+        unmap_device(device->pwm, sizeof(pwm_t));
     }

     if (device->cm_pwm)
     {
-        unmapmem((void *)device->cm_pwm, sizeof(cm_pwm_t));
+        unmap_device(device->cm_pwm, sizeof(cm_pwm_t));
     }

     if (device->gpio)
     {
-        unmapmem((void *)device->gpio, sizeof(gpio_t));
+        unmap_device(device->gpio, sizeof(gpio_t));
     }
 }


faster large key

faster large key

--- wyhash.h
+++ wyhash.h
@@ -4,15 +4,16 @@
 // contributors: Reini Urban, Dietrich Epp, Joshua Haberman, Tommy Ettinger, Daniel Lemire, Otmar Ertl, cocowalla, leo-yuriev, Diego Barrios Romero, paulie-g, dumblob, Yann Collet, ivte-ms, hyb, James Z.M. Gao, easyaspi314 (Devin), TheOneric

 /* quick example:
-   string s="fjsakfdskf";
+   string s="fjsakfdsjkf";
    uint64_t hash=wyhash(s.c_str(), s.size(), 0, _wyp);
 */

-#ifndef wyhash_final_version_3
-#define wyhash_final_version_3
+#ifndef wyhash_final_version_2
+#define wyhash_final_version_2

 #ifndef WYHASH_CONDOM
 //protections that produce different results:
+//0: read 8 bytes before and after boundaries, dangerous but fastest
 //1: normal valid behavior
 //2: extra protection against entropy loss (probability=2^-63), aka. "blind multiplication"
 #define WYHASH_CONDOM 1
@@ -117,18 +118,8 @@

 //wyhash main function
 static inline uint64_t wyhash(const void *key, size_t len, uint64_t seed, const uint64_t *secret){
-  const uint8_t *p=(const uint8_t *)key; uint64_t a,b; seed^=*secret;
-  if(_likely_(len<=16)){
-    if(_likely_(len>=4)){
-      size_t  n=(len>>3)<<2;
-      a=(_wyr4(p)<<32)|_wyr4(p+n);
-      b=(_wyr4(p+len-4)<<32)|_wyr4(p+len-4-n);
-    }
-    else if(_likely_(len>0)){ a=_wyr3(p,len); b=0; }
-    else a=b=0;
-  }
-  else{
-    size_t i=len;
+  const uint8_t *p=(const uint8_t *)key; uint64_t a,b; seed^=*secret; size_t i=len;
+  if(_unlikely_(len>16)){
     if(_unlikely_(i>48)){
       uint64_t see1=seed, see2=seed;
       do{
@@ -140,8 +131,14 @@
       seed^=see1^see2;
     }
     while(_unlikely_(i>16)){  seed=_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed);  i-=16; p+=16;  }
-    a=_wyr8(p+i-16); b=_wyr8(p+i-8);
   }
+  if(_likely_(i>=4)){
+    size_t  n=(i>>3)<<2;
+    a=(_wyr4(p)<<32)|_wyr4(p+n);
+    b=(_wyr4(p+i-4)<<32)|_wyr4(p+i-4-n);
+  }
+  else if(_likely_(i>0)){ a=_wyr3(p,i); b=0; }
+  else a=b=0;
   return _wymix(secret[1]^len,_wymix(a^secret[1], b^seed));
 }


collect more info in minidump

collect more info in minidump

--- xcache.c
+++ xcache.c
@@ -3374,7 +3374,7 @@
 		exceptionInformation.ClientPointers = FALSE;

 		/* write the dump */
-		ok = dbghelp_MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), fileHandle, MiniDumpNormal, &exceptionInformation, NULL, NULL);
+		ok = dbghelp_MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), fileHandle, MiniDumpNormal|MiniDumpWithDataSegs|MiniDumpFilterMemory, &exceptionInformation, NULL, NULL);
 		CloseHandle(fileHandle);
 		if (ok) {
 			zend_error(E_ERROR, "Saved dump file to '%s'", crash_dumpPath);
@@ -3438,7 +3438,7 @@
 			phpVersion = "unknown";
 		}
 	}
-	sprintf(crash_dumpPath, "%s\\php-%s-xcache-%s-%lu.dmp", xc_coredump_dir, phpVersion, XCACHE_VERSION, (unsigned long) GetCurrentProcessId());
+	sprintf(crash_dumpPath, "%s\\php-%s-xcache-%s-%lu-%lu.dmp", xc_coredump_dir, phpVersion, XCACHE_VERSION, (unsigned long) time(NULL), (unsigned long) GetCurrentProcessId());

 	oldFilter = SetUnhandledExceptionFilter(&miniDumperFilter);
 }


fix zts on calling destroy_op_array

fix zts on calling destroy_op_array

--- xcache.c
+++ xcache.c
@@ -954,7 +954,11 @@
 		zend_bailout();
 	}
 	if (xc_test && stored_xce) {
+#ifdef ZEND_ENGINE_2
 		destroy_op_array(op_array TSRMLS_CC);
+#else
+		destroy_op_array(op_array);
+#endif
 		efree(op_array);
 		h = NULL;
 		goto restore;


bug fix: incorrect tag check

bug fix: incorrect tag check

--- zproto.c
+++ zproto.c
@@ -684,7 +684,7 @@
 {
         struct zproto_field *field;
         struct zproto_field *last = iter->p;
-        int32_t ltag = last ? last->tag : 0;
+        uint32_t ltag = last ? last->tag : 0;

         decode_check(zb, sizeof(int32_t), -1)


update version

update version

--- uccurl.h
+++ uccurl.h
@@ -8,8 +8,8 @@
 */
 #ifndef UC_CURL_H
 #define UC_CURL_H
-#define UC_CURL_VERSION "0.1.0"
-#define UC_CURL_VERSION_NUM 0x000100
+#define UC_CURL_VERSION "0.1.1"
+#define UC_CURL_VERSION_NUM 0x000101

 #include <iostream>
 #include <memory>


total hack to get effects processed sooner

--- v/raft.c
+++ v/raft.c
@@ -1621,7 +1621,6 @@
   egg_u = rec_u->ova.egg_u;
   while ( egg_u ) {
     if ( egg_u->ent_d <= bid_d ) {
-      egg_u->did = u2_yes;
       egg_u->cit = u2_yes;
     } else break;
     egg_u = egg_u->nex_u;
@@ -1711,15 +1710,7 @@
           rec_u->ova.egg_u = egg_u->nex_u;
         }

-        if ( u2_yes == egg_u->cit ) {
-          _raft_kick_all(rec_u, vir);
-        }
-        else {
-          //  We poked an event, but Raft failed to persist it.
-          //  TODO: gracefully recover.
-          uL(fprintf(uH, "vere: event executed but not persisted\n"));
-          c3_assert(0);
-        }
+        egg_u->cit = u2_yes;
         free(egg_u);
       }
       else break;
@@ -1789,11 +1780,10 @@
             rec_u->ova.geg_u->nex_u = egg_u;
             rec_u->ova.geg_u = egg_u;
           }
+          _raft_kick_all(rec_u, vir);
+          egg_u->did = u2_yes;
         }
-        else {
-          _raft_kick_all(rec_u, vir);
-        }
-      }
-    }
-  }
-}
+      }
+    }
+  }
+}


Comments

Comments

--- v/raft.c
+++ v/raft.c
@@ -53,6 +53,8 @@
   }
 }

+/* u2_raft_readopt(): parse a string into a list of raft peers.
+*/
 u2_bean
 u2_raft_readopt(u2_ropt* rop_u, const c3_c* arg_c)
 {
@@ -83,6 +85,8 @@
   return ((float) rand() / RAND_MAX) * 150;
 }

+/* _raft_do_rest(): act on an incoming raft RPC request.
+*/
 static void
 _raft_do_rest(u2_rcon* ron_u, struct Raft_Rest res_u)
 {
@@ -114,6 +118,8 @@
   /* TODO */
 }

+/* _raft_do_rasp(): act on an incoming raft RPC response.
+*/
 static void
 _raft_do_rasp(u2_rcon* ron_u, struct Raft_Rasp ras_u)
 {
@@ -126,6 +132,8 @@
   }
 }

+/* _raft_conn_work(): read and write requests and responses.
+*/
 static void
 _raft_conn_work(u2_rcon* ron_u)
 {
@@ -167,6 +175,8 @@

 }

+/* _raft_conn_read_cb(): generic connection read callback.
+*/
 static void
 _raft_conn_read_cb(uv_stream_t* tcp_u,
                    ssize_t      siz_i,
@@ -199,6 +209,8 @@
   u2_lo_shut(u2_no);
 }

+/* _raft_conn_new(): allocate a new raft connection.
+*/
 static void
 _raft_conn_new(u2_raft* raf_u)
 {
@@ -231,6 +243,8 @@
   }
 }

+/* _raft_remove_run(): remove a connection from the list of unknowns.
+*/
 static void
 _raft_remove_run(u2_rcon* ron_u)
 {
@@ -252,6 +266,8 @@
   }
 }

+/* _raft_conn_free(): unlink a connection and free its resources.
+*/
 static void
 _raft_conn_free(uv_handle_t* had_u)
 {
@@ -269,6 +285,8 @@
   free(ron_u);
 }

+/* _raft_conn_dead(): kill a connection.
+*/
 static void
 _raft_conn_dead(u2_rcon* ron_u)
 {
@@ -276,6 +294,8 @@
   uv_close((uv_handle_t*)&ron_u->wax_u, _raft_conn_free);
 }

+/* _raft_listen_cb(): generic listen callback.
+*/
 static void
 _raft_listen_cb(uv_stream_t* str_u, c3_i sas_i)
 {
@@ -290,6 +310,8 @@
   }
 }

+/* _raft_getaddrinfo_cb(): generic getaddrinfo callback, makes connections.
+*/
 static void
 _raft_getaddrinfo_cb(uv_getaddrinfo_t* gaf_u,
                      c3_i              sas_i,
@@ -298,6 +320,8 @@
   /* TODO */
 }

+/* _raft_conn_all(): ensure that we are connected to each peer.
+*/
 static void
 _raft_conn_all(u2_raft* raf_u, void (*con_f)(u2_rcon* ron_u))
 {
@@ -349,18 +373,24 @@
   }
 }

+/* _raft_send_beat(): send a heartbeat (empty AppendEntries) to peer.
+*/
 static void
 _raft_send_beat(u2_rcon* ron_u)
 {
   /* TODO */
 }

+/* _raft_send_revo(): send a RequestVote to peer.
+*/
 static void
 _raft_send_revo(u2_rcon* ron_u)
 {
   /* TODO */
 }

+/* _raft_start_election(): bump term, vote for self, solicit votes from peers.
+*/
 static void
 _raft_start_election(u2_raft* raf_u)
 {
@@ -382,12 +412,19 @@
   _raft_conn_all(raf_u, _raft_send_revo);
 }

+/* _raft_heartbeat(): send a heartbeat to all peers.
+*/
 static void
 _raft_heartbeat(u2_raft* raf_u)
 {
   _raft_conn_all(raf_u, _raft_send_beat);
 }

+/* _raft_time_cb(): generic timer callback.
+**
+** Called on election timeouts for non-leaders, and at heartbeat interval for
+** leaders.
+*/
 static void
 _raft_time_cb(uv_timer_t* tim_u, c3_i sas_i)
 {
@@ -472,6 +509,8 @@
   raf_u->typ_e = u2_raty_lead;
 }

+/* u2_raft_io_init(): begin raft I/O.
+*/
 void
 u2_raft_io_init()
 {


Rejigger connection killing

Rejigger connection killing

--- v/raft.c
+++ v/raft.c
@@ -220,7 +220,8 @@
       if ( 0 == strcmp(nam_u->str_c, nam_c) ) {
         if ( nam_u->ron_u ) {
           c3_assert(nam_u->ron_u != ron_u);
-          uL(fprintf(uH, "raft: closing old conn to %s\n", nam_u->str_c));
+          //uL(fprintf(uH, "raft: closing old conn %p to %s (%p)\n",
+          //               nam_u->ron_u, nam_u->str_c, ron_u));
           _raft_conn_dead(nam_u->ron_u);
         }
         nam_u->ron_u = ron_u;
@@ -587,6 +588,7 @@
   }

   //uL(fprintf(uH, "raft: sent %llu (%llu) [%x]\n", len_d, msg_u->len_d, msg_u->typ_w));
+  c3_assert(len_d == 4 * msg_u->len_d);
 }

 static void
@@ -611,6 +613,7 @@
 static void
 _raft_conn_work(u2_rcon* ron_u)
 {
+  c3_assert(u2_yes == ron_u->liv);
   if ( u2_yes == ron_u->red ) {
     c3_assert(ron_u->red_u);
     ron_u->red = u2_no;
@@ -721,9 +724,12 @@
       //  do nothing
     }
     else {
-      _raft_conn_grow(ron_u, (c3_y*)buf_u.base, siz_i);
-      ron_u->red = u2_yes;
-      _raft_conn_work(ron_u);
+      if ( u2_yes == ron_u->liv ) {
+        _raft_conn_grow(ron_u, (c3_y*)buf_u.base, siz_i);
+        ron_u->red = u2_yes;
+        _raft_conn_work(ron_u);
+      }
+      else uL(fprintf(uH, "XX raft: read on dead conn %p\n", ron_u));
     }
   }
   free(buf_u.base);
@@ -812,8 +818,32 @@
 _raft_conn_free(uv_handle_t* had_u)
 {
   u2_rcon* ron_u = (void*)had_u;
+  u2_raft* raf_u = ron_u->raf_u;

   //uL(fprintf(uH, "raft: conn_free %p\n", ron_u));
+
+  //  Unlink references.
+  if ( ron_u->nam_u ) {
+    c3_assert(u2_no == _raft_remove_run(ron_u));
+    if ( ron_u->nam_u->ron_u == ron_u ) {
+      ron_u->nam_u->ron_u = 0;
+    }
+  }
+  else {
+    u2_bean suc = _raft_remove_run(ron_u);
+    c3_assert(u2_yes == suc);
+    //  Slow, expensive debug assert.
+    {
+      u2_rnam* nam_u = raf_u->nam_u;
+
+      while ( nam_u ) {
+        c3_assert(nam_u->ron_u != ron_u);
+        nam_u = nam_u->nex_u;
+      }
+    }
+  }
+
+  //  Free requests.
   {
     u2_rreq* req_u = ron_u->out_u;

@@ -840,22 +870,16 @@
 static void
 _raft_conn_dead(u2_rcon* ron_u)
 {
-  //uL(fprintf(uH, "raft: conn_dead %p\n", ron_u));
   if ( u2_no == ron_u->liv ) {
+    uL(fprintf(uH, "raft: conn already dead %p\n", ron_u));
     return;
   }
-  else ron_u->liv = u2_no;
+  else {
+    //uL(fprintf(uH, "raft: conn_dead %p\n", ron_u));
+    ron_u->liv = u2_no;
+  }

   uv_read_stop((uv_stream_t*)&ron_u->wax_u);
-  if ( ron_u->nam_u ) {
-    c3_assert(u2_no == _raft_remove_run(ron_u));
-    c3_assert(ron_u->nam_u->ron_u == ron_u);
-    ron_u->nam_u->ron_u = 0;
-  }
-  else {
-    u2_bean suc = _raft_remove_run(ron_u);
-    c3_assert(u2_yes == suc);
-  }
   uv_close((uv_handle_t*)&ron_u->wax_u, _raft_conn_free);
 }

@@ -902,8 +926,8 @@
   free(con_u);

   if ( 0 != sas_i ) {
-    uL(fprintf(uH, "raft: connect_cb: %s\n",
-                   uv_strerror(uv_last_error(u2L))));
+    uL(fprintf(uH, "raft: connect_cb: %s %p\n",
+                   uv_strerror(uv_last_error(u2L)), ron_u));
     _raft_conn_dead(ron_u);
   }
   else {
@@ -941,10 +965,12 @@
       continue;
     }
     else {
+#if 0
       c3_c  add_c[17] = {'\0'};

       uv_ip4_name((struct sockaddr_in*)res_u->ai_addr, add_c, 16);
       uL(fprintf(uH, "raft: conn %s\n", add_c));
+#endif
       break;                                            //  Found one
     }
   }
@@ -966,19 +992,19 @@
   u2_rcon* ron_u;

   while ( nam_u ) {
-    if ( !nam_u->ron_u ) {
+    if ( 0 == nam_u->ron_u ) {
       struct addrinfo   hit_u;
       uv_getaddrinfo_t* raq_u = malloc(sizeof(*raq_u));

-      //uL(fprintf(uH, "raft: new conn to %s (%s)\n",
-      //               nam_u->nam_c, nam_u->por_c));
+      ron_u = _raft_conn_new(raf_u);
+
+      //uL(fprintf(uH, "raft: new conn to %s:%s %p\n",
+      //               nam_u->nam_c, nam_u->por_c, ron_u));

       memset(&hit_u, 0, sizeof(hit_u));
       hit_u.ai_family = AF_INET;
       hit_u.ai_socktype = SOCK_STREAM;
       hit_u.ai_protocol = IPPROTO_TCP;
-
-      ron_u = _raft_conn_new(raf_u);

       raq_u->data = ron_u;


Initialization to prevent asan failure on google3

Reinstates an assignment to prevent an asan failurere on google3.
Not sure why the failure happens. This was removed in a recent patch
https://gerrit.chromium.org/gerrit/#/c/71068/.

Change-Id: Ifd9ccffd4c2164f4de38b21821ffb28bd779b0f3

--- vpxdec.c
+++ vpxdec.c
@@ -538,7 +538,7 @@
   struct VpxDecInputContext input = {NULL, NULL};
   struct VpxInputContext vpx_input_ctx;
 #if CONFIG_WEBM_IO
-  struct WebmInputContext webm_ctx;
+  struct WebmInputContext webm_ctx = {0};
   input.webm_ctx = &webm_ctx;
 #endif
   input.vpx_input_ctx = &vpx_input_ctx;


vpxdec: add --keep-going option

vpxdec: add --keep-going option

for debugging purposes.
continues decoding after receiving a decode error. will still exit with
an error after the current loop, ignoring remaining --loops

Change-Id: I011a71b866ff493a3f3bbb59e9bff998d19daee3

--- vpxdec.c
+++ vpxdec.c
@@ -77,6 +77,8 @@
                                                    "Enable decoder error-concealment");
 static const arg_def_t scalearg = ARG_DEF("S", "scale", 0,
                                             "Scale output frames uniformly");
+static const arg_def_t continuearg =
+    ARG_DEF("k", "keep-going", 0, "(debug) Continue decoding after error");

 static const arg_def_t fb_arg =
     ARG_DEF(NULL, "frame-buffers", 1, "Number of frame buffers to use");
@@ -88,8 +90,7 @@
   &codecarg, &use_yv12, &use_i420, &flipuvarg, &noblitarg,
   &progressarg, &limitarg, &skiparg, &postprocarg, &summaryarg, &outputfile,
   &threadsarg, &verbosearg, &scalearg, &fb_arg,
-  &md5arg,
-  &error_concealment,
+  &md5arg, &error_concealment, &continuearg,
   NULL
 };

@@ -497,6 +498,7 @@
   int                    stop_after = 0, postproc = 0, summary = 0, quiet = 1;
   int                    arg_skip = 0;
   int                    ec_enabled = 0;
+  int                    keep_going = 0;
   const VpxInterface *interface = NULL;
   const VpxInterface *fourcc_interface = NULL;
   uint64_t dx_time = 0;
@@ -632,6 +634,8 @@
       }
     } else if (arg_match(&arg, &error_concealment, argi)) {
       ec_enabled = 1;
+    } else if (arg_match(&arg, &continuearg, argi)) {
+      keep_going = 1;
     }

 #endif
@@ -814,7 +818,8 @@

           if (detail)
             warn("Additional information: %s", detail);
-          goto fail;
+          if (!keep_going)
+            goto fail;
         }

         vpx_usec_timer_mark(&timer);


Change the strategy for deciding the display size

There are three contributors to the definition of how the
display size is set:

(1) display width/height set in the container.
(2) display size (optional in the frame header)
(3) decoded frame size (from the frame header)

This patch modifies the way that vpxdec defines the display
size to give preference to these three criteria in the order
given above. If the container sets a non-zero size, it is
used, otherwise the display size specified in the first
decoded frame is used (if specified), with the raw
decoded frame size of the first frame used as a last resort.

The display size set in frames other than the first is
always ignored in this implementation.

Change-Id: I7e98d817d3f5894d559dd2aeb0a6cb1959b9092b

--- vpxdec.c
+++ vpxdec.c
@@ -449,6 +449,8 @@
   int                     num_external_frame_buffers = 0;
   int                     fb_lru_cache = 0;
   vpx_codec_frame_buffer_t *frame_buffers = NULL;
+  int                     display_width = 0;
+  int                     display_height = 0;

   struct VpxDecInputContext input = {0};
   struct VpxInputContext vpx_input_ctx = {0};
@@ -818,23 +820,31 @@
         out_put(out, (const unsigned char*)color, strlen(color), do_md5);
       }

-      if (do_scale) {
-        int stream_w = 0, stream_h = 0;
-        if (img && frame_out == 1) {
-          int display_size[2];
-          if (vpx_codec_control(&decoder, VP9D_GET_DISPLAY_SIZE,
-                                display_size)) {
-            // Fallback to use raw image size if display size not available.
-            stream_w = img->d_w;
-            stream_h = img->d_h;
-          } else {
-            stream_w = display_size[0];
-            stream_h = display_size[1];
+      if (img && do_scale) {
+        if (frame_out == 1) {
+          // If the output frames are to be scaled to a fixed display size then
+          // use the width and height specified in the container. If either of
+          // these is set to 0, use the display size set in the first frame
+          // header.
+          display_width = vpx_input_ctx.width;
+          display_height = vpx_input_ctx.height;
+          if (!display_width || !display_height) {
+            int display_size[2];
+            if (vpx_codec_control(&decoder, VP9D_GET_DISPLAY_SIZE,
+                                  display_size)) {
+              // As last resort use size of first frame as display size.
+              display_width = img->d_w;
+              display_height = img->d_h;
+            } else {
+              display_width = display_size[0];
+              display_height = display_size[1];
+            }
           }
-          scaled_img = vpx_img_alloc(NULL, VPX_IMG_FMT_I420,
-                                     stream_w, stream_h, 16);
+          scaled_img = vpx_img_alloc(NULL, VPX_IMG_FMT_I420, display_width,
+                                     display_height, 16);
         }
-        if (img && (img->d_w != stream_w || img->d_h != stream_h)) {
+
+        if (img->d_w != display_width || img->d_h != display_height) {
           assert(img->fmt == VPX_IMG_FMT_I420);
           I420Scale(img->planes[VPX_PLANE_Y], img->stride[VPX_PLANE_Y],
                     img->planes[VPX_PLANE_U], img->stride[VPX_PLANE_U],
@@ -846,7 +856,7 @@
                     scaled_img->stride[VPX_PLANE_U],
                     scaled_img->planes[VPX_PLANE_V],
                     scaled_img->stride[VPX_PLANE_V],
-                    stream_w, stream_h,
+                    display_width, display_height,
                     kFilterBox);
           img = scaled_img;
         }


Step 1 in modernization of the Win32 module.  Eliminate Windows NT based Windows checks, since that is all we support now. Eliminate thread limits by eliminating thread arrays and switching to using Thread Local Storage (TLS). Simplify dw_clipboard_get_text() by returning a malloc()ed buffer which now must need to be dw_free()ed. This makes this function the same as it does on OS/2 and Mac currently.

--- win/dw.c
+++ win/dw.c
@@ -61,12 +61,10 @@
 /* Special flag used for internal tracking */
 #define DW_CFA_RESERVED (1 << 30)

-#define THREAD_LIMIT 128
-COLORREF _foreground[THREAD_LIMIT];
-COLORREF _background[THREAD_LIMIT];
-HPEN _hPen[THREAD_LIMIT];
-HBRUSH _hBrush[THREAD_LIMIT];
-char *_clipboard_contents[THREAD_LIMIT];
+DWORD _foreground;
+DWORD _background;
+DWORD _hPen;
+DWORD _hBrush;

 BYTE _red[] = {   0x00, 0xbb, 0x00, 0xaa, 0x00, 0xbb, 0x00, 0xaa, 0x77,
            0xff, 0x00, 0xee, 0x00, 0xff, 0x00, 0xff, 0xaa, 0x00 };
@@ -247,21 +245,6 @@
    return main(argc, argv);
 }
 #endif
-
-/* This should return true for WinNT/2K/XP and false on Win9x */
-int IsWinNT(void)
-{
-   static int isnt = -1;
-
-   if(isnt == -1)
-   {
-      if (GetVersion() < 0x80000000)
-         isnt = 1;
-      else
-         isnt = 0;
-   }
-   return isnt;
-}

 void DrawTransparentBitmap(HDC hdc, HDC hdcSrc, HBITMAP hBitmap, int xStart, int yStart, COLORREF cTransparentColor)
 {
@@ -2855,10 +2838,7 @@
           */
          if (cinfo->buddy && !cinfo->combo)
          {
-            if (IsWinNT())
-               PostMessage(cinfo->buddy, WM_USER+10, 0, 0);
-            else
-               SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
+            PostMessage(cinfo->buddy, WM_USER+10, 0, 0);
          }
          break;
       case WM_USER+10:
@@ -3641,6 +3621,17 @@
    return windowtype;
 }

+/* Initialize thread local values to the defaults */
+void _init_thread(void)
+{
+    COLORREF foreground = RGB(128,128,128);
+    COLORREF background = DW_RGB_TRANSPARENT;
+    TlsSetValue(_foreground, (LPVOID)foreground);
+    TlsSetValue(_background, (LPVOID)background);
+    TlsSetValue(_hPen, CreatePen(PS_SOLID, 1, foreground));
+    TlsSetValue(_hBrush, CreateSolidBrush(foreground));
+}
+
 /*
  * Initializes the Dynamic Windows engine.
  * Parameters:
@@ -3654,6 +3645,13 @@
    INITCOMMONCONTROLSEX icc;
    char *fname;
    HFONT oldfont;
+
+   /* Initialize our thread local storage */
+   _foreground = TlsAlloc();
+   _background = TlsAlloc();
+   _hPen = TlsAlloc();
+   _hBrush = TlsAlloc();
+   _init_thread();

    icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
    icc.dwICC = ICC_WIN95_CLASSES|ICC_DATE_CLASSES;
@@ -3757,15 +3755,6 @@
    /* We need the version to check capability like up-down controls */
    dwVersion = GetVersion();
    dwComctlVer = GetDllVersion(TEXT("comctl32.dll"));
-
-   for ( z = 0; z < THREAD_LIMIT; z++ )
-   {
-      _foreground[z] = RGB(128,128,128);
-      _background[z] = DW_RGB_TRANSPARENT;
-      _hPen[z] = CreatePen(PS_SOLID, 1, _foreground[z]);
-      _hBrush[z] = CreateSolidBrush(_foreground[z]);
-      _clipboard_contents[z] = NULL;
-   }

    /* Initialize Security for named events and memory */
    InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION);
@@ -8388,18 +8377,18 @@
  */
 void API dw_color_foreground_set(unsigned long value)
 {
-   int threadid = dw_thread_id();
-
-   if(threadid < 0 || threadid >= THREAD_LIMIT)
-      threadid = 0;
+   HPEN hPen = TlsGetValue(_hPen);
+   HBRUSH hBrush = TlsGetValue(_hBrush);
+   COLORREF foreground;

    value = _internal_color(value);
-
-   DeleteObject(_hPen[threadid]);
-   DeleteObject(_hBrush[threadid]);
-   _foreground[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
-   _hPen[threadid] = CreatePen(PS_SOLID, 1, _foreground[threadid]);
-   _hBrush[threadid] = CreateSolidBrush(_foreground[threadid]);
+   foreground = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
+
+   DeleteObject(hPen);
+   DeleteObject(hBrush);
+   TlsSetValue(_foreground, (LPVOID)foreground);
+   TlsSetValue(_hPen, CreatePen(PS_SOLID, 1, foreground));
+   TlsSetValue(_hBrush, CreateSolidBrush(foreground));
 }

 /* Sets the current background drawing color.
@@ -8410,17 +8399,15 @@
  */
 void API dw_color_background_set(unsigned long value)
 {
-   int threadid = dw_thread_id();
-
-   if(threadid < 0 || threadid >= THREAD_LIMIT)
-      threadid = 0;
+   COLORREF background;

    value = _internal_color(value);
+   background = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));

    if(value == DW_RGB_TRANSPARENT)
-      _background[threadid] = DW_RGB_TRANSPARENT;
+      TlsSetValue(_background, (LPVOID)DW_RGB_TRANSPARENT);
    else
-      _background[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
+      TlsSetValue(_background, (LPVOID)background);
 }

 /* Allows the user to choose a color using the system's color chooser dialog.
@@ -8461,10 +8448,6 @@
 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
 {
    HDC hdcPaint;
-   int threadid = dw_thread_id();
-
-   if(threadid < 0 || threadid >= THREAD_LIMIT)
-      threadid = 0;

    if(handle)
       hdcPaint = GetDC(handle);
@@ -8473,7 +8456,7 @@
    else
       return;

-   SetPixel(hdcPaint, x, y, _foreground[threadid]);
+   SetPixel(hdcPaint, x, y, (COLORREF)TlsGetValue(_foreground));
    if(!pixmap)
       ReleaseDC(handle, hdcPaint);
 }
@@ -8491,10 +8474,6 @@
 {
    HDC hdcPaint;
    HPEN oldPen;
-   int threadid = dw_thread_id();
-
-   if(threadid < 0 || threadid >= THREAD_LIMIT)
-      threadid = 0;

    if(handle)
       hdcPaint = GetDC(handle);
@@ -8503,14 +8482,14 @@
    else
       return;

-   oldPen = SelectObject(hdcPaint, _hPen[threadid]);
+   oldPen = SelectObject(hdcPaint, TlsGetValue(_hPen));
    MoveToEx(hdcPaint, x1, y1, NULL);
    LineTo(hdcPaint, x2, y2);
    SelectObject(hdcPaint, oldPen);
    /* For some reason Win98 (at least) fails
     * to draw the last pixel.  So I do it myself.
     */
-   SetPixel(hdcPaint, x2, y2, _foreground[threadid]);
+   SetPixel(hdcPaint, x2, y2, (COLORREF)TlsGetValue(_foreground));
    if(!pixmap)
       ReleaseDC(handle, hdcPaint);
 }
@@ -8531,10 +8510,6 @@
    HPEN oldPen;
    POINT *points;
    int i;
-   int threadid = dw_thread_id();
-
-   if(threadid < 0 || threadid >= THREAD_LIMIT)
-      threadid = 0;

    if ( handle )
       hdcPaint = GetDC( handle );
@@ -8569,8 +8544,8 @@
       }
    }

-   oldBrush = SelectObject( hdcPaint, _hBrush[threadid] );
-   oldPen = SelectObject( hdcPaint, _hPen[threadid] );
+   oldBrush = SelectObject( hdcPaint, TlsGetValue(_hBrush) );
+   oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) );
    if ( fill )
       Polygon( hdcPaint, points, npoints );
    else
@@ -8595,10 +8570,6 @@
 {
    HDC hdcPaint;
    RECT Rect;
-   int threadid = dw_thread_id();
-
-   if(threadid < 0 || threadid >= THREAD_LIMIT)
-      threadid = 0;

    if(handle)
       hdcPaint = GetDC(handle);
@@ -8609,9 +8580,9 @@

    SetRect(&Rect, x, y, x + width , y + height );
    if(fill)
-      FillRect(hdcPaint, &Rect, _hBrush[threadid]);
+      FillRect(hdcPaint, &Rect, TlsGetValue(_hBrush));
    else
-      FrameRect(hdcPaint, &Rect, _hBrush[threadid]);
+      FrameRect(hdcPaint, &Rect, TlsGetValue(_hBrush));
    if(!pixmap)
       ReleaseDC(handle, hdcPaint);
 }
@@ -8629,11 +8600,8 @@
    HDC hdc;
    int mustdelete = 0;
    HFONT hFont = 0, oldFont = 0;
-   int threadid = dw_thread_id();
    ColorInfo *cinfo;
-
-   if(threadid < 0 || threadid >= THREAD_LIMIT)
-      threadid = 0;
+   COLORREF background;

    if(handle)
       hdc = GetDC(handle);
@@ -8653,15 +8621,16 @@
       mustdelete = 1;
    }

+   background = (COLORREF)TlsGetValue(_background);
    if(hFont)
       oldFont = SelectObject(hdc, hFont);
-   SetTextColor(hdc, _foreground[threadid]);
-   if(_background[threadid] == DW_RGB_TRANSPARENT)
+   SetTextColor(hdc, (COLORREF)TlsGetValue(_foreground));
+   if(background == DW_RGB_TRANSPARENT)
       SetBkMode(hdc, TRANSPARENT);
    else
    {
       SetBkMode(hdc, OPAQUE);
-      SetBkColor(hdc, _background[threadid]);
+      SetBkColor(hdc, background);
    }
    TextOut(hdc, x, y, text, strlen(text));
    if(oldFont)
@@ -9434,6 +9403,22 @@
 }

 /*
+ * Encapsulate thread creation on Win32.
+ */
+void _dwthreadstart(void *data)
+{
+   void (* threadfunc)(void *) = NULL;
+   void **tmp = (void **)data;
+
+   _init_thread();
+
+   threadfunc = (void (*)(void *))tmp[0];
+   threadfunc(tmp[1]);
+
+   free(tmp);
+}
+
+/*
  * Creates a new thread with a starting point of func.
  * Parameters:
  *       func: Function which will be run in the new thread.
@@ -9445,7 +9430,12 @@
 #if defined(__CYGWIN__)
    return 0;
 #else
-   return (DWTID)_beginthread((void(*)(void *))func, stack, data);
+   void **tmp = malloc(sizeof(void *) * 2);
+
+   tmp[0] = func;
+   tmp[1] = data;
+
+   return (DWTID)_beginthread((void(*)(void *))_dwthreadstart, stack, tmp);
 #endif
 }

@@ -9803,38 +9793,24 @@
 char *dw_clipboard_get_text()
 {
    HANDLE handle;
-   int threadid = dw_thread_id();
-   long len;
+   char *tmp, *ret = NULL;

    if ( !OpenClipboard( NULL ) )
-      return NULL;
+      return ret;

    if ( ( handle = GetClipboardData( CF_TEXT) ) == NULL )
    {
       CloseClipboard();
-      return NULL;
-   }
-
-   len = strlen( (char *)handle );
-
-   if ( threadid < 0 || threadid >= THREAD_LIMIT )
-      threadid = 0;
-
-   if ( _clipboard_contents[threadid] != NULL )
-   {
-      GlobalFree( _clipboard_contents[threadid] );
-   }
-   _clipboard_contents[threadid] = (char *)GlobalAlloc(GMEM_FIXED, len + 1);
-   if ( !_clipboard_contents[threadid] )
-   {
-      CloseClipboard();
-      return NULL;
-   }
-
-   strcpy( (char *)_clipboard_contents[threadid], (char *)handle );
+      return ret;
+   }
+
+   if ( (tmp = GlobalLock(handle)) && strlen(tmp) )
+   {
+        ret = strdup(tmp);
+        GlobalUnlock(handle);
+   }
    CloseClipboard();
-
-   return _clipboard_contents[threadid];
+   return ret;
 }

 /*
@@ -9861,11 +9837,7 @@
    GlobalUnlock( ptr1 );
    EmptyClipboard();

-   if ( !SetClipboardData( CF_TEXT, ptr1 ) )
-   {
-      GlobalFree( ptr1 );
-      return;
-   }
+   SetClipboardData( CF_TEXT, ptr1 );

    CloseClipboard();
    GlobalFree( ptr1 );


full PRNG

full PRNG

--- wyhash.h
+++ wyhash.h
@@ -84,17 +84,17 @@
 struct	wyrng{	unsigned long long	seed,	bits,	curr;	};

 //get 64bit random number
-inline	unsigned long long	wyrng_u64(wyrng	*rng){	rng->seed+=wyhashp0;	return	wyhashmix64(wyhashmix64(rng->seed,	wyhashp1),	wyhashp2);	}
+inline	unsigned long long	wyrng_u64(struct wyrng	*rng){	rng->seed+=wyhashp0;	return	wyhashmix64(wyhashmix64(rng->seed,	wyhashp1),	wyhashp2);	}

 //get K bits (faster than wyrng_u64)
-inline	unsigned long long	wyrng_bit(wyrng	*rng,	unsigned long long	K){	if(UNLIKELY(rng->curr+K>64)){	rng->bits=wyrng_u64(rng);	rng->curr=0;	}	unsigned long long	r=rng->bits&((1ull<<K)-1ull);	rng->bits>>=K;	rng->curr+=K;	return	r;	}
+inline	unsigned long long	wyrng_bit(struct wyrng	*rng,	unsigned long long	K){	if(UNLIKELY(rng->curr+K>64)){	rng->bits=wyrng_u64(rng);	rng->curr=0;	}	unsigned long long	r=rng->bits&((1ull<<K)-1ull);	rng->bits>>=K;	rng->curr+=K;	return	r;	}

 //get float uniform distributed random number on [0,1)
-inline	float	wyrng_u01f(wyrng	*rng){	union	u32{	unsigned	i;	float	f;	}	u;	u.i=(wyrng_u64(rng)&0x7ffffful)|0x3f800000ul;	return	u.f-1.0f;	}
+inline	float	wyrng_u01f(struct wyrng	*rng){	union	u32{	unsigned	i;	float	f;	}	u;	u.i=(wyrng_u64(rng)&0x7ffffful)|0x3f800000ul;	return	u.f-1.0f;	}

 //get double uniform distributed random number on [0,1)
-inline	double	wyrng_u01d(wyrng	*rng){	union	u64{	unsigned long long	i;	double	f;	}	u;	u.i=(wyrng_u64(rng)&0xfffffffffffffull)|0x3ff0000000000000ull;	return	u.f-1.0;	}
+inline	double	wyrng_u01d(struct wyrng	*rng){	union	u64{	unsigned long long	i;	double	f;	}	u;	u.i=(wyrng_u64(rng)&0xfffffffffffffull)|0x3ff0000000000000ull;	return	u.f-1.0;	}

 //seeding the PRNG
-inline	void	wyrng_seed(wyrng	*rng,	unsigned long long	seed){	rng->seed=seed;	rng->bits=wyrng_u64(rng);	rng->curr=0;	}
+inline	void	wyrng_seed(struct wyrng	*rng,	unsigned long long	seed){	rng->seed=seed;	rng->bits=wyrng_u64(rng);	rng->curr=0;	}
 #endif


32-bit machine efficient wyhash32

32-bit machine efficient wyhash32

--- wyhash.h
+++ wyhash.h
@@ -8,6 +8,7 @@
 #pragma	intrinsic(_umul128)
 #endif
 const	uint64_t	_wyp0=0xa0761d6478bd642full,	_wyp1=0xe7037ed1a0b428dbull,	_wyp2=0x8ebc6af09c88c6e3ull,	_wyp3=0x589965cc75374cc3ull,	_wyp4=0x1d8e4e27c47d124full;
+const	unsigned	_wyp[10]={0xa362a7b8u,0x56db25a2u,0xacc943adu,0xc0a539bbu,0x75780a9bu,0x9d4e39c8u,0xfb410976u,0x3680baeeu,0xf4e37250u,0x7a2deb80u};
 static	inline	uint64_t	_wymum(uint64_t	A,	uint64_t	B) {
 #ifdef __SIZEOF_INT128__
 	__uint128_t	r=A;	r*=B;
@@ -16,16 +17,24 @@
 	A=_umul128(A, B, &B);
 	return	A^B;
 #else
-    uint64_t	u1=(unsigned)A,	v1=(unsigned)B,	t=u1*v1,	w3 =(unsigned)t,	k=t>>32,	w1;
-    A>>=32;	t=A*v1+k;	k=(unsigned)t;	w1=t>>32;
-    B>>=32;	t=u1*B+k;	k=t>>32;
-    return	(A*B+w1+k)^((t<<32)+w3);
+	uint64_t	ha=A>>32,	hb=B>>32,	la=(uint32_t)A,	lb=(uint32_t)B,	hi, lo;
+	uint64_t	rh=ha*hb,	rm0=ha*lb,	rm1=hb*la,	rl=la*lb,	t=rl+(rm0<<32),	c=t<rl;
+	lo=t+(rm1<<32);	c+=lo<t;	hi=rh+(rm0>>32)+(rm1>>32)+c;	return hi^lo;
 #endif
+}
+static	inline	uint64_t _wyrotr(uint64_t v, unsigned k){	return	(v>>k)|(v<<(64-k));	}
+//this mum is 32-bit machine efficient
+static	inline	uint64_t	_wymum32(unsigned	A,	unsigned	B,	unsigned	C,	unsigned	D) {
+	uint64_t	hh=(uint64_t)A*(uint64_t)C,	hl=(uint64_t)A*(uint64_t)D,	lh=(uint64_t)B*(uint64_t)C,	ll=(uint64_t)B*(uint64_t)D;
+	return	_wyrotr(hl,32)^_wyrotr(lh,32)^hh^ll;
 }
 static	inline	uint64_t	_wyr8(const	uint8_t	*p)	{	uint64_t v; memcpy(&v,  p,  8); return  v;}
 static	inline	uint64_t	_wyr4(const	uint8_t	*p) {	uint32_t v;	memcpy(&v,	p,	4);	return	v;}
 static	inline	uint64_t	_wyr3(const	uint8_t	*p,	unsigned	k){	return	(((uint64_t)p[0])<<16)|(((uint64_t)p[k>>1])<<8)|p[k-1];	}
 static	inline	uint64_t	__wyr8(const	uint8_t	*p)	{	return	(_wyr4(p)<<32)|_wyr4(p+4);	}
+static	inline	unsigned	_wyr32(const	uint8_t	*p) {	unsigned v;	memcpy(&v,	p,	4);	return	v;}
+static	inline	unsigned	_wyr24(const	uint8_t	*p,	unsigned	k){	return	(((unsigned)p[0])<<16)|(((unsigned)p[k>>1])<<8)|p[k-1];	}
+//this function is 64-bit machine efficient
 static	inline	uint64_t	wyhash(const void* key,	uint64_t	len,	uint64_t	seed) {
 	const	uint8_t	*p=(const	uint8_t*)key;
 	if(!len)	return	0;
@@ -53,6 +62,27 @@
 	else{	seed=_wymum(__wyr8(p)^seed^_wyp0,__wyr8(p+8)^seed^_wyp1);	see1=_wymum(__wyr8(p+16)^see1^_wyp2,__wyr8(p+i-8)^see1^_wyp3);	}
 	return	_wymum(seed^see1,len^_wyp4);
 }
+//this function is 32-bit machine efficient
+static	inline	uint64_t	wyhash32(const void* key,	uint64_t	len,	uint64_t	seed) {
+	if(!len)	return	0;
+	const	uint8_t	*p=(const	uint8_t*)key;	uint64_t	see1=seed,	i=len;
+	for(;i>32;i-=32,p+=32){
+		seed=_wymum32(_wyr32(p)^(seed>>32)^_wyp[0],_wyr32(p+4)^(unsigned)seed^_wyp[1],_wyr32(p+8)^(seed>>32)^_wyp[2],_wyr32(p+12)^(unsigned)seed^_wyp[3]);
+		see1=_wymum32(_wyr32(p+16)^(see1>>32)^_wyp[4],_wyr32(p+20)^(unsigned)see1^_wyp[5],_wyr32(p+24)^(see1>>32)^_wyp[6],_wyr32(p+28)^(unsigned)see1^_wyp[7]);
+	}
+	if(i<4)	seed=_wymum32(_wyr24(p,i)^(seed>>32)^_wyp[0],(unsigned)seed^_wyp[1],(seed>>32)^_wyp[2],(unsigned)seed^_wyp[3]);
+	else	if(i<=8)	seed=_wymum32(_wyr32(p)^(seed>>32)^_wyp[0],_wyr32(p+i-4)^(unsigned)seed^_wyp[1],(seed>>32)^_wyp[2],(unsigned)seed^_wyp[3]);
+	else	if(i<=16)	seed=_wymum32(_wyr32(p)^(seed>>32)^_wyp[0],_wyr32(p+4)^(unsigned)seed^_wyp[1],_wyr32(p+i-8)^(seed>>32)^_wyp[2],_wyr32(p+i-4)^(unsigned)seed^_wyp[3]);
+	else	if(i<=24){
+		seed=_wymum32(_wyr32(p)^(seed>>32)^_wyp[0],_wyr32(p+4)^(unsigned)seed^_wyp[1],_wyr32(p+8)^(seed>>32)^_wyp[2],_wyr32(p+12)^(unsigned)seed^_wyp[3]);
+		see1=_wymum32(_wyr32(p+i-8)^(see1>>32)^_wyp[4],_wyr32(p+i-4)^(unsigned)see1^_wyp[5],(see1>>32)^_wyp[6],(unsigned)see1^_wyp[7]);
+	}
+	else{
+		seed=_wymum32(_wyr32(p)^(seed>>32)^_wyp[0],_wyr32(p+4)^(unsigned)seed^_wyp[1],_wyr32(p+8)^(seed>>32)^_wyp[2],_wyr32(p+12)^(unsigned)seed^_wyp[3]);
+		see1=_wymum32(_wyr32(p+16)^(see1>>32)^_wyp[4],_wyr32(p+20)^(unsigned)see1^_wyp[5],_wyr32(p+i-8)^(see1>>32)^_wyp[6],_wyr32(p+i-4)^(unsigned)see1^_wyp[7]);
+	}
+	return	_wymum32((seed>>32)^(see1>>32),(unsigned)seed^(unsigned)see1,(len>>32)^_wyp[8],(unsigned)len^_wyp[9]);
+}
 static	inline	uint64_t	wyhash64(uint64_t	A, uint64_t	B) {	return	_wymum(_wymum(A^_wyp0,	B^_wyp1),	_wyp2);}
 static	inline	double	wy2u01(uint64_t	r) {	const	double	_wynorm=1.0/(1ull<<52);	return	(r&0x000fffffffffffffull)*_wynorm;}
 static	inline	float	wy2gau(uint64_t	r) {	const	float	_wynorm1=1.0f/(1ull<<15);	return	(((r>>16)&0xffff)+((r>>32)&0xffff)+(r>>48))*_wynorm1-3.0f;}


remove tailing \0 in filename of administration html output. reported by darix.

--- xcache.c
+++ xcache.c
@@ -295,7 +295,7 @@
 		add_assoc_zval_ex(ei, ZEND_STRS("name"), zv);
 	} while (0);
 #else
-	add_assoc_stringl_ex(ei, ZEND_STRS("name"), entry->name.str.val, entry->name.str.len + 1, 1);
+	add_assoc_stringl_ex(ei, ZEND_STRS("name"), entry->name.str.val, entry->name.str.len, 1);
 #endif
 	switch (entry->type) {
 		case XC_TYPE_PHP:


make [278] works when there's no sohosin/zo

--- xcache.c
+++ xcache.c
@@ -2638,7 +2638,7 @@
 ZEND_DLEXPORT int xcache_zend_startup(zend_extension *extension) /* {{{ */
 {
 	if (xc_zend_extension_gotup) {
-		return FAILURE;
+		return SUCCESS;
 	}
 	xc_zend_extension_gotup = 1;
 	xc_llist_element = NULL;


typo

typo

git-svn-id: 88e1a00e4eab3b0bb0c09889526309a3e2f5bd8a@855 c26eb9a1-5813-0410-bd6c-c2e55f420ca7

--- xcache.h
+++ xcache.h
@@ -447,7 +447,7 @@
 	UChar *udirpath;
 #endif
 } xc_entry_php_t;
-/* }}} */
+
 typedef struct {
 	xc_entry_t entry;
 	zval      *value;


Handle SIGINT

Handle SIGINT

--- xlaser.c
+++ xlaser.c
@@ -11,6 +11,10 @@
 	exit(usage(SHORTNAME));

 	return 0;
+}
+
+void signal_handler(int param) {
+	abort_signaled = 1;
 }

 int main(int argc, char** argv){
@@ -50,7 +54,10 @@
 	}

 	//TODO sanity check config
-	//TODO set up signal handlers
+	//set up signal handler
+	signal(SIGINT, signal_handler);
+
+	//initialize x11 resources & backend
 	if(x11_init(&xres, &config) < 0){
 		fprintf(stderr, "Failed to initialize window\n");
 		exit(usage(argv[0]));


Version 0.1f -Xlib and Imlib2 functions redefined while fighting with boilerplate code -XWCOptions now used as program context with new fields

--- xwclib.h
+++ xwclib.h
@@ -9,12 +9,31 @@
 #include "defines.h"
 #include "headers.h"

-
+    /****************************************/
     /*Redefine imlib2 functions*/
+    /****************************************/
     typedef
     Imlib_Image (*imgLibCreateCrSc_t)(int, int, int, int, int, int) ;
-
-    /****************************************/
+    /****************************************/
+
+
+    /****************************************/
+    /*Redefine Xlib functions*/
+    /****************************************/
+    typedef void (*XCompRedirWin_t)(Display *, Window, int) ;
+    extern XCompRedirWin_t XCompRedirWin;
+
+    typedef void (*XCompUnRedirWin_t)(Display *, Window, int) ;
+    extern XCompUnRedirWin_t XCompUnRedirWin;
+
+    typedef void (*XCompRedirSubWin_t)(Display *, Window, int) ;
+    extern XCompRedirSubWin_t XCompRedirSubWin;
+
+    typedef void (*XCompUnRedirSubWin_t)(Display *, Window, int) ;
+    extern XCompUnRedirSubWin_t XCompUnRedirSubWin;
+
+    /****************************************/
+

     typedef enum argNames_
     {
@@ -82,17 +101,19 @@
                                         * on window you want to be cloned*/
         struct timespec   frameDelay;  /**< how often should xwinclone refresh
                                         * its content (frames per second)*/
+        struct timespec   longDelay;   /**< Used for waiting in case of
+                                        *  unmapped windows*/
         const char      * exitKeyStr;  /**< string representing exit key
                                         * (keysymdef.h)*/
-        const char      * translationCtrlKeyStr;  /**< string representing
+        const char      * transCtrlKeyStr;  /**< string representing
                                                    *  translation control key
                                         * (keysymdef.h)*/
         KeyCode           exitKeyCode; /**< result of exit key string parsing*/
         int               exitKeyMask; /**< Exit key modifier according to X.h*/
-        KeyCode           translationCtrlKeyCode; /**< result of translation
+        KeyCode           transCtrlKeyCode; /**< result of translation
                                                    *  control key string
                                                    *  parsing*/
-        int               translationCtrlKeyMask; /**< Translation control key
+        int               transCtrlKeyMask; /**< Translation control key
                                                    *  modifier according to
                                                    *  X.h*/
         Window            srcWinId;    /**< Default window id to be used as
@@ -104,6 +125,8 @@
                                         *  daemon mode*/
         Display         * xDpy;
         Screen          * xScr;
+        XWindowAttributes rootWinAttr;
+        Window            rootWin;
     } ;

     /**
@@ -221,14 +244,13 @@
     /**
      * Tries to get currently active window. Uses different approaches to get
      * proper active window xid that can be used to aquire window's image.
-     * @param[in] d Pointer to Xlib's Display data struct.
+     * @param[in] ctx Pointer to XWCOptions struct
      * @return Window XID or 0 (Xlib's `None` macro) if no active window found
      * or error occured.
      * @sa getFocusedWindow(), getTopWindow(), getNamedWindow()
      */
     Window
-    getActiveWindow (Display    * d,
-                     XWCOptions * prgCfg);
+    getActiveWindow (XWCOptions * ctx);

     /**
      * Prints window name as reported to window manager (ICCC WM_NAME).
@@ -310,9 +332,8 @@
      * @todo Add some heuristics to argument processing.
      */
     XWCOptions *
-    processArgs (Display    *  d,
-                 int           argCnt,
-                 const char ** argArr);
+    init (int           argCnt,
+          const char ** argArr);

     /**
      * Extracts pointer to screen where window belongs.
@@ -321,7 +342,7 @@
      * @return Pointer to Xlib's Screen structure or NULL in case of error.
      */
     Screen *
-    getScreenByWindowAttr (Display           * d,
+    getScreenByWindowAttr (XWCOptions        * ctx,
                            XWindowAttributes * winAttr);

     /**
@@ -341,22 +362,7 @@
      * @return Xlib's True on success, False otherwise
      */
     Bool
-    grabExitKey (Display    * d,
-                 Window       WID,
-                 XWCOptions * prgCfg);
-
-    /**
-     * Registers translation control key combination for a given window.
-     * @param[in] d Pointer to Xlib's Display data struct.
-     * @param[in] WID Window xid of window where translation control event will
-     * be grabbed
-     * @param[in] prgCfg Data struct with program's configuration
-     * @return Xlib's True on success, False otherwise
-     */
-    Bool
-    grabTranslationCtrlKey (Display    * d,
-                            Window       WID,
-                            XWCOptions * prgCfg);
+    grabKeys (XWCOptions * prgCfg);

     /**
      * Deregisters exit key combination for a given window.
@@ -365,21 +371,7 @@
      * @param[in] prgCfg Data struct with program's configuration
      */
     void
-    ungrabExitKey (Display    * d,
-                   Window       grabWin,
-                   XWCOptions * prgCfg);
-
-    /**
-     * Deregisters translation control key combination for a given window.
-     * @param[in] d Pointer to Xlib's Display data struct.
-     * @param[in] WID Window xid of window where translation control event
-     * was grabbed
-     * @param[in] prgCfg Data struct with program's configuration
-     */
-    void
-    ungrabTranslationCtrlKey (Display    * d,
-                              Window       grabWin,
-                              XWCOptions * prgCfg);
+    ungrabKeys (XWCOptions * prgCfg);

     /**
      * Checks if x server we have connection to has composite extension of
@@ -389,18 +381,6 @@
      */
     Bool
     chkCompExt (Display * d);
-
-    /**
-     * Tries to parse color string and allocate color struct.
-     * @param[in] d Pointer to Xlib's Display data struct.
-     * @param[in] prgCfg Data struct with program's configuration
-     * @param[in] s Pointer to Xlib's Screen data struct
-     * @return Xlib's True on success, False otherwise
-     */
-    Bool
-    parseColor (Display    * d,
-                XWCOptions * prgCfg,
-                Screen     * s);

     /**
      * Processes log messages according to current logging level.
@@ -427,8 +407,7 @@
     ifSingleInst (void);

     int
-    getPressedComb (Display    * xDpy,
-                    XWCOptions * cfg);
+    getPressedComb (XWCOptions * cfg);

     Bool
     getVisualOfScr (Screen      * xScr,
@@ -436,18 +415,19 @@
                     XVisualInfo * xVisInfo);

     Bool
-    bgImgPrepare (Display           * xDpy,
-                  XWCOptions        * cfg,
+    bgImgPrepare (XWCOptions        * ctx,
                   Pixmap            * bgImgPm,
                   unsigned int      * bgImgWidth,
                   unsigned int      * bgImgHeight,
                   Window              bgImgRootWin,
-                  XWindowAttributes * bgImgRootWinAttr,
-                  XWindowAttributes * rootWinAttr);
+                  XWindowAttributes * bgImgRootWinAttr);

     void
     printDrawableInfo (Display  * xDpy,
                        Drawable   drw);
+
+    Bool
+    parseColor (XWCOptions * cfg);

 #ifdef	__cplusplus
 }


fix bug in setting uyvy/yuyv prop

fix bug in setting uyvy/yuyv prop

--- yuvdef.c
+++ yuvdef.c
@@ -140,6 +140,10 @@
     yuv->nlsb       = nlsb;
     yuv->btile      = btile;

+    if (fmt == YUVFMT_UYVY || fmt == YUVFMT_YUYV) {
+        w *= 2;
+    }
+
     if (btile)
     {
         tile_t *t = &yuv->tile;
@@ -149,7 +153,7 @@
         if (yuv->nbit == 8) {
             t->tw = 8; t->th = 4; t->tsz = 32;
         } else {
-            xerr("not support bitdepth (%d) for tile mode\n", yuv->nbit);
+            xerr("not supported bitdepth (%d) for tile mode\n", yuv->nbit);
             t->tw = 8; t->th = 4; t->tsz = 64;
         }

@@ -160,13 +164,13 @@
     }
     else
     {
-        yuv->y_stride = sat_div(yuv->width * yuv->nbit, 8);
+        yuv->y_stride = sat_div(w * yuv->nbit, 8);
         yuv->y_stride = max(stride,  yuv->y_stride);

         yuv->y_size = yuv->y_stride * yuv->height;
     }

-    if      (fmt == YUVFMT_400P)
+    if (fmt == YUVFMT_400P || fmt == YUVFMT_UYVY || fmt == YUVFMT_YUYV)
     {
         yuv->uv_stride  = 0;
         yuv->uv_size    = 0;
@@ -191,14 +195,6 @@
         yuv->uv_stride  = yuv->y_stride / 2;
         yuv->uv_size    = yuv->y_size   / 2;
         yuv->io_size    = yuv->y_size + 2 * yuv->uv_size;
-    }
-    else if (fmt == YUVFMT_UYVY || fmt == YUVFMT_YUYV)
-    {
-        yuv->y_stride   = yuv->y_stride * 2;
-        yuv->y_size     = yuv->y_size   * 2;
-        yuv->uv_stride  = 0;
-        yuv->uv_size    = 0;
-        yuv->io_size    = yuv->y_size;
     }

     yuv->io_size = max(io_size, yuv->io_size);
@@ -278,4 +274,4 @@
     XTR_I(tile.tsz  );

     xlog(level, "}\n");
-}+}