updated esp8266 example, server is pretty efficient now (50req/s on hello world example)

--- esp8266/user/user_main.c
+++ esp8266/user/user_main.c
@@ -10,11 +10,11 @@
 #include <unistd.h>

 #define ESP8266 1
+#define UREQ_USE_FILESYSTEM 1

 #include "../../ureq.c"

-#define UREQ_USE_FILESYSTEM 1
-#define MAX_CONNS 32
+#define MAX_CONNS 4

 struct HttpConnection {
     struct espconn *c;
@@ -56,9 +56,9 @@
     int l;
     struct espconn *pespconn = (struct espconn *)arg;

-    HttpRequest r = ureq_init();
+    HttpRequest r = ureq_init(data);

-    ureq_run(&r, data);
+    ureq_run(&r);

     int i;
     for(i=0; i<MAX_CONNS; i++) {
@@ -75,14 +75,14 @@
     conns[i].r = r;
     conns[i].id = i;

-    espconn_sent(pespconn, r.response, r.len);
+    espconn_sent(pespconn, r.response.data, r.len);
     os_printf("Request %s from %d.%d.%d.%d. Status: %d.\n",
         r.url,
         pespconn->proto.tcp->remote_ip[0],
         pespconn->proto.tcp->remote_ip[1],
         pespconn->proto.tcp->remote_ip[2],
         pespconn->proto.tcp->remote_ip[3],
-        r.responseCode);
+        r.response.code);
 }

 struct HttpConnection *getHttpConnection(void *arg) {
@@ -99,15 +99,15 @@
     struct espconn *pespconn = (struct espconn *)arg;
     struct HttpConnection *c = getHttpConnection(pespconn);

-    if (c->r.responseCode == 404) {
+    if (c->r.response.code == 404) {
         ureq_close(&c->r);
         espconn_disconnect(pespconn);
         conns[c->id].c = NULL;
         return;
     }

-    ureq_run(&c->r, "");
-    espconn_sent(pespconn, c->r.response, c->r.len);
+    ureq_run(&c->r);
+    espconn_sent(pespconn, c->r.response.data, c->r.len);
     if (c->r.len < 512) {
         ureq_close(&c->r);
         espconn_disconnect(pespconn);
@@ -118,6 +118,12 @@

 void ICACHE_FLASH_ATTR ssConnCb(void *arg) {
     struct espconn *pespconn = (struct espconn *)arg;
+
+    if (pespconn->link_cnt > 0) {
+        espconn_disconnect(pespconn);
+        os_printf("Too many connections at once.\n");
+        return;
+    }

     espconn_regist_recvcb(pespconn, ssRecvCb);
     espconn_regist_sentcb(pespconn, ssSentCb);


tools lib traceevent: Add copyright header

Adding a missing copyright header to parse-utils.c. Assuminng that the
license is LGPL like the rest of the trace-cmd library code.

Signed-off-by: Jon Stanley <eae456df2612dfe944a62cb428fc77e4c00aa33e@gmail.com>
Acked-by: Steven Rostedt <43232e92d70cc7aa53504ad0397085ee47bad87f@goodmis.org>
Cc: Steven Rostedt <43232e92d70cc7aa53504ad0397085ee47bad87f@goodmis.org>
Link: http://lkml.kernel.org/r/1347127251-4695-1-git-send-email-eae456df2612dfe944a62cb428fc77e4c00aa33e@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <293abb6b76d7791c0732cc517d38c4b5c734b87f@redhat.com>

--- tools/lib/traceevent/parse-utils.c
+++ tools/lib/traceevent/parse-utils.c
@@ -1,3 +1,22 @@
+/*
+ * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License (not later!)
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not,  see <http://www.gnu.org/licenses>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>


internal change

internal change

PiperOrigin-RevId: 163088509

--- tensorflow/core/platform/macros.h
+++ tensorflow/core/platform/macros.h
@@ -20,6 +20,7 @@
 #if (defined(__GNUC__) || defined(__APPLE__)) && !defined(SWIG)
 // Compiler supports GCC-style attributes
 #define TF_ATTRIBUTE_NORETURN __attribute__((noreturn))
+#define TF_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline))
 #define TF_ATTRIBUTE_NOINLINE __attribute__((noinline))
 #define TF_ATTRIBUTE_UNUSED __attribute__((unused))
 #define TF_ATTRIBUTE_COLD __attribute__((cold))
@@ -33,6 +34,7 @@
 #elif defined(COMPILER_MSVC)
 // Non-GCC equivalents
 #define TF_ATTRIBUTE_NORETURN __declspec(noreturn)
+#define TF_ATTRIBUTE_ALWAYS_INLINE
 #define TF_ATTRIBUTE_NOINLINE
 #define TF_ATTRIBUTE_UNUSED
 #define TF_ATTRIBUTE_COLD
@@ -43,6 +45,7 @@
 #else
 // Non-GCC equivalents
 #define TF_ATTRIBUTE_NORETURN
+#define TF_ATTRIBUTE_ALWAYS_INLINE
 #define TF_ATTRIBUTE_NOINLINE
 #define TF_ATTRIBUTE_UNUSED
 #define TF_ATTRIBUTE_COLD


Create 1.11.02.c

Create 1.11.02.c

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


Fixed small bug within GetInput function. Minor updates.

--- AsciiEngine/Input.c
+++ AsciiEngine/Input.c
@@ -51,7 +51,7 @@
     case VK_RBUTTON:
       return GLOBAL_INPUTS.R_Button;
     default:
-      return TRUE;
+      return FALSE;
   }
 }

@@ -152,10 +152,13 @@
         }
         break;
       case MOUSE_EVENT:
-        GLOBAL_INPUTS.xPos = eventBuffer[i_events].Event.MouseEvent.dwMousePosition.X;
-        GLOBAL_INPUTS.yPos = eventBuffer[i_events].Event.MouseEvent.dwMousePosition.Y;
         GLOBAL_INPUTS.L_Button = eventBuffer[i_events].Event.MouseEvent.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED;
         GLOBAL_INPUTS.R_Button = eventBuffer[i_events].Event.MouseEvent.dwButtonState & RIGHTMOST_BUTTON_PRESSED;
+        if( eventBuffer[i_events].Event.MouseEvent.dwEventFlags == MOUSE_MOVED )
+        {
+          GLOBAL_INPUTS.xPos = eventBuffer[i_events].Event.MouseEvent.dwMousePosition.X;
+          GLOBAL_INPUTS.yPos = eventBuffer[i_events].Event.MouseEvent.dwMousePosition.Y;
+        }
         if(GLOBAL_INPUTS.L_Button)
         {
           GLOBAL_INPUTS.xPosAtLastLeftClick = GLOBAL_INPUTS.xPos;
@@ -166,6 +169,7 @@
           GLOBAL_INPUTS.xPosAtLastRightClick = GLOBAL_INPUTS.xPos;
           GLOBAL_INPUTS.yPosAtLastRightClick = GLOBAL_INPUTS.yPos;
         }
+        break;
       }
     }
     FlushConsoleInputBuffer( INPUT_HANDLE );


Correct Serialise393/477 version annotations

--- src/Protocol/ChunkDataSerializer.h
+++ src/Protocol/ChunkDataSerializer.h
@@ -36,8 +36,9 @@
 	void Serialize47 (const std::vector<cClientHandle *> & a_SendTo);  // Release 1.8
 	void Serialize107(const std::vector<cClientHandle *> & a_SendTo);  // Release 1.9
 	void Serialize110(const std::vector<cClientHandle *> & a_SendTo);  // Release 1.9.4
-	template <auto Palette> void Serialize393(const std::vector<cClientHandle *> & a_SendTo);  // Release 1.13 - 1.13.1
-	void Serialize477(const std::vector<cClientHandle *> & a_SendTo);  // Release 1.13 - 1.13.1
+	template <auto Palette>
+	void Serialize393(const std::vector<cClientHandle *> & a_SendTo);  // Release 1.13 - 1.13.2
+	void Serialize477(const std::vector<cClientHandle *> & a_SendTo);  // Release 1.14 - 1.14.4

 	/** Writes all blocks in a chunk section into a series of Int64.
 	Writes start from the bit directly subsequent to the previous write's end, possibly crossing over to the next Int64. */


include/llvm/DataTypes.h includes this #define so we don't need it anymore

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@3709 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/AsmParser/ParserInternals.h
+++ lib/AsmParser/ParserInternals.h
@@ -8,8 +8,6 @@
 #ifndef PARSER_INTERNALS_H
 #define PARSER_INTERNALS_H

-#define __STDC_LIMIT_MACROS
-#include "llvm/BasicBlock.h"
 #include "llvm/Constants.h"
 #include "llvm/iOther.h"
 #include "llvm/Function.h"


optimisation and list into vecter end

optimisation and list into vecter end


restart: fix potential double free

restart: fix potential double free

--- restart.c
+++ restart.c
@@ -148,6 +148,7 @@
     // have to re-assign it into the structure anyway.
     if (c->line != NULL) {
         free(c->line);
+        c->line = NULL;
     }

     if (getline(&line, &len, c->f) != -1) {
@@ -198,6 +199,7 @@
         } else {
             // FIXME: proper error chain.
             fprintf(stderr, "[restart] invalid metadata line:\n\n%s\n", line);
+            free(line);
             return RESTART_BADLINE;
         }
     } else {


Nightly Version

Nightly Version

--- Common/vtkVersion.h
+++ Common/vtkVersion.h
@@ -31,7 +31,7 @@

 #include "vtkObject.h"

-#define VTK_SOURCE_VERSION "vtk version " VTK_VERSION ", vtk source $Revision: 1.1441 $, $Date: 2002-12-26 03:45:10 $ (GMT)"
+#define VTK_SOURCE_VERSION "vtk version " VTK_VERSION ", vtk source $Revision: 1.1442 $, $Date: 2002-12-27 03:45:05 $ (GMT)"

 class VTK_COMMON_EXPORT vtkVersion : public vtkObject


Nightly Version

Nightly Version

--- Common/vtkVersion.h
+++ Common/vtkVersion.h
@@ -31,7 +31,7 @@

 #include "vtkObject.h"

-#define VTK_SOURCE_VERSION "vtk version " VTK_VERSION ", vtk source $Revision: 1.1428 $, $Date: 2002-12-13 03:45:03 $ (GMT)"
+#define VTK_SOURCE_VERSION "vtk version " VTK_VERSION ", vtk source $Revision: 1.1429 $, $Date: 2002-12-14 03:45:04 $ (GMT)"

 class VTK_COMMON_EXPORT vtkVersion : public vtkObject


Add Documentation

Add Documentation

--- Containers/vector.h
+++ Containers/vector.h
@@ -56,7 +56,13 @@
      ******************/

     /**
+        @brief Returns a reference to the element at specified location `position`, with bounds
+               checking. If `position` is not within the range of the container, an exception of
+               type `std::out_of_range` is thrown.

+        @note http://en.cppreference.com/w/cpp/container/vector/at
+        @param position the position of the element to return.
+        @return reference to the requested element.
      */
     reference at(size_type position) {
         if (position < this->element_count) {
@@ -66,7 +72,13 @@
     }

     /**
+        @brief Returns a reference to the element at specified location `position`, with bounds
+               checking. If `position` is not within the range of the container, an exception of
+               type `std::out_of_range` is thrown.

+        @note http://en.cppreference.com/w/cpp/container/vector/at
+        @param position the position of the element to return.
+        @return reference to the requested element.
      */
     const_reference at(size_type position) const {
         if (position < this->element_count) {


carbon fixes.

carbon fixes.

--- pr/src/md/mac/macio.c
+++ pr/src/md/mac/macio.c
@@ -333,7 +333,7 @@
 #pragma unused (mode)

 	OSErr 				err;
- 	ParamBlockRec 		pb;
+ 	HParamBlockRec 		pb;
 	char	 			*macFileName = NULL;
 	Str255				pascalName;
 	PRInt8 				perm;
@@ -375,13 +375,13 @@

 	pb.ioParam.ioMisc 			= NULL;

-	err = PBOpenSync(&pb);
+	err = PBHOpenSync(&pb);
 	if (err == noErr)
 		return pb.ioParam.ioRefNum;
 	else if ((err != fnfErr) || ((oflag & O_CREAT) == 0))
 		goto ErrorExit;

-	err = PBCreateSync(&pb);
+	err = PBHCreateSync(&pb);
 	if (err == noErr)
 		goto open;


Fix gen9p.c's formatting.

Fix gen9p.c's formatting.

    Had an extra arg.

--- 6/genp9.c
+++ 6/genp9.c
@@ -304,7 +304,7 @@
            if (v->lit.strval.len > 0)
                fprintf(fd, "DATA %s+%zd(SB)/8,$%s+0(SB)\n", name, off, lbl);
            else
-               fprintf(fd, "DATA %s+%zd(SB)/8,$0\n", name, off, lbl);
+               fprintf(fd, "DATA %s+%zd(SB)/8,$0\n", name, off);
            fprintf(fd, "DATA %s+%zd(SB)/8,$%zd\n", name, off+8, v->lit.strval.len);
            break;
         case Lfunc:


Report parameter request changes in UpdateDeviceParams

--- Alc/ALc.c
+++ Alc/ALc.c
@@ -1139,26 +1139,52 @@

     if((device->Flags&DEVICE_RUNNING))
         return ALC_TRUE;
-
-    LockDevice(device);
-    TRACE("Format pre-setup: %s%s, %s, %uhz%s, %u update size x%d\n",
-          DevFmtChannelsString(device->FmtChans),
-          (device->Flags&DEVICE_CHANNELS_REQUEST)?" (requested)":"",
-          DevFmtTypeString(device->FmtType), device->Frequency,
-          (device->Flags&DEVICE_FREQUENCY_REQUEST)?" (requested)":"",
-          device->UpdateSize, device->NumUpdates);
-    if(ALCdevice_ResetPlayback(device) == ALC_FALSE)
-    {
-        UnlockDevice(device);
-        return ALC_FALSE;
-    }
-    device->Flags |= DEVICE_RUNNING;
-    TRACE("Format post-setup: %s%s, %s, %uhz%s, %u update size x%d\n",
-          DevFmtChannelsString(device->FmtChans),
-          (device->Flags&DEVICE_CHANNELS_REQUEST)?" (requested)":"",
-          DevFmtTypeString(device->FmtType), device->Frequency,
-          (device->Flags&DEVICE_FREQUENCY_REQUEST)?" (requested)":"",
-          device->UpdateSize, device->NumUpdates);
+    else
+    {
+        enum DevFmtChannels schans;
+        enum DevFmtType stype;
+        ALCuint freq;
+
+        LockDevice(device);
+
+        freq = device->Frequency;
+        schans = device->FmtChans;
+        stype = device->FmtType;
+
+        TRACE("Format pre-setup: %s%s, %s, %uhz%s, %u update size x%d\n",
+              DevFmtChannelsString(device->FmtChans),
+              (device->Flags&DEVICE_CHANNELS_REQUEST)?" (requested)":"",
+              DevFmtTypeString(device->FmtType), device->Frequency,
+              (device->Flags&DEVICE_FREQUENCY_REQUEST)?" (requested)":"",
+              device->UpdateSize, device->NumUpdates);
+        if(ALCdevice_ResetPlayback(device) == ALC_FALSE)
+        {
+            UnlockDevice(device);
+            return ALC_FALSE;
+        }
+        device->Flags |= DEVICE_RUNNING;
+
+        if(device->FmtChans != schans)
+        {
+            if((device->Flags&DEVICE_CHANNELS_REQUEST))
+                ERR("Failed to set %s, got %s instead\n",
+                    DevFmtChannelsString(schans),
+                    DevFmtChannelsString(device->FmtChans));
+            device->Flags &= ~DEVICE_CHANNELS_REQUEST;
+        }
+        if(device->Frequency != freq)
+        {
+            if((device->Flags&DEVICE_FREQUENCY_REQUEST))
+                ERR("Failed to set %uhz, got %uhz instead\n",
+                    freq, device->Frequency);
+            device->Flags &= ~DEVICE_FREQUENCY_REQUEST;
+        }
+
+        TRACE("Format post-setup: %s, %s, %uhz, %u update size x%d\n",
+              DevFmtChannelsString(device->FmtChans),
+              DevFmtTypeString(device->FmtType), device->Frequency,
+              device->UpdateSize, device->NumUpdates);
+    }

     aluInitPanning(device);


Bugfix for infinite CPU spin on TERM=dumb, which has no terminfo key strings

--- driver-ti.c
+++ driver-ti.c
@@ -152,7 +152,11 @@
       unsigned char min, max;
       // Find the real bounds
       for(min = 0; !nar->arr[min]; min++)
-        ;
+        if(min == 255 && !nar->arr[min]) {
+          free(nar);
+          return (struct trie_node_arr*)new_node_arr(1, 0);
+        }
+
       for(max = 0xff; !nar->arr[max]; max--)
         ;


Use an RMS limit of -3dB for the output limiter

--- Alc/ALc.c
+++ Alc/ALc.c
@@ -1740,8 +1740,8 @@

 struct Compressor *CreateDeviceLimiter(const ALCdevice *device)
 {
-    return CompressorInit(0.0f, 0.0f, AL_FALSE, AL_FALSE, 0.0f, 0.0f, 0.5f, 2.0f,
-                          0.0f, -0.5f, 3.0f, device->Frequency);
+    return CompressorInit(0.0f, 0.0f, AL_FALSE, AL_TRUE, 0.0f, 0.0f, 0.5f, 2.0f,
+                          0.0f, -3.0f, 3.0f, device->Frequency);
 }

 /* UpdateClockBase


Include header file

Include header file

--- dt_easter.c
+++ dt_easter.c
@@ -24,6 +24,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "dt.h"
+#include "dt_easter.h"

 /*
  * Easter algorithms by Al Petrofsky, San Mateo County, California, U.S.A.


Remove some more hungarian notation

Remove some more hungarian notation

--- Alc/ALc.c
+++ Alc/ALc.c
@@ -367,7 +367,7 @@
 static ALCcontext *volatile GlobalContext = NULL;

 /* Device Error */
-static volatile ALCenum g_eLastNullDeviceError = ALC_NO_ERROR;
+static volatile ALCenum LastNullDeviceError = ALC_NO_ERROR;

 // Default context extensions
 static const ALchar alExtList[] =
@@ -1027,7 +1027,7 @@
     if(device)
         device->LastError = errorCode;
     else
-        g_eLastNullDeviceError = errorCode;
+        LastNullDeviceError = errorCode;
 }

@@ -1640,7 +1640,7 @@

 // This should probably move to another c file but for now ...
-ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei SampleSize)
+ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei samples)
 {
     ALCdevice *device = NULL;
     ALCenum err;
@@ -1653,7 +1653,7 @@
         return NULL;
     }

-    if(SampleSize <= 0)
+    if(samples <= 0)
     {
         alcSetError(NULL, ALC_INVALID_VALUE);
         return NULL;
@@ -1694,7 +1694,7 @@
         return NULL;
     }

-    device->UpdateSize = SampleSize;
+    device->UpdateSize = samples;
     device->NumUpdates = 1;

     LockLists();
@@ -1716,13 +1716,13 @@
     return device;
 }

-ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *pDevice)
+ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *Device)
 {
     ALCdevice *volatile*list;

     LockLists();
     list = &DeviceList;
-    while(*list && *list != pDevice)
+    while(*list && *list != Device)
         list = &(*list)->next;

     if(!*list || (*list)->Type != Capture)
@@ -1735,9 +1735,9 @@
     *list = (*list)->next;
     UnlockLists();

-    ALCdevice_CloseCapture(pDevice);
-
-    ALCdevice_DecRef(pDevice);
+    ALCdevice_CloseCapture(Device);
+
+    ALCdevice_DecRef(Device);

     return ALC_TRUE;
 }
@@ -1812,7 +1812,7 @@
         ALCdevice_DecRef(device);
     }
     else
-        errorCode = ExchangeInt(&g_eLastNullDeviceError, ALC_NO_ERROR);
+        errorCode = ExchangeInt(&LastNullDeviceError, ALC_NO_ERROR);

     return errorCode;
 }
@@ -1839,9 +1839,9 @@

 /* alcGetString
  *
- * Returns information about the Device, and error strings
+ * Returns information about the device, and error strings
  */
-ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *pDevice,ALCenum param)
+ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *Device, ALCenum param)
 {
     const ALCchar *value = NULL;

@@ -1876,10 +1876,10 @@
         break;

     case ALC_ALL_DEVICES_SPECIFIER:
-        if(VerifyDevice(pDevice))
-        {
-            value = pDevice->DeviceName;
-            ALCdevice_DecRef(pDevice);
+        if(VerifyDevice(Device))
+        {
+            value = Device->DeviceName;
+            ALCdevice_DecRef(Device);
         }
         else
         {
@@ -1889,10 +1889,10 @@
         break;

     case ALC_CAPTURE_DEVICE_SPECIFIER:
-        if(VerifyDevice(pDevice))
-        {
-            value = pDevice->DeviceName;
-            ALCdevice_DecRef(pDevice);
+        if(VerifyDevice(Device))
+        {
+            value = Device->DeviceName;
+            ALCdevice_DecRef(Device);
         }
         else
         {
@@ -1910,48 +1910,48 @@
         if(!alcAllDeviceList)
             ProbeAllDeviceList();

-        pDevice = VerifyDevice(pDevice);
+        Device = VerifyDevice(Device);

         free(alcDefaultAllDeviceSpecifier);
         alcDefaultAllDeviceSpecifier = strdup(alcAllDeviceList ?
                                               alcAllDeviceList : "");
         if(!alcDefaultAllDeviceSpecifier)
-            alcSetError(pDevice, ALC_OUT_OF_MEMORY);
+            alcSetError(Device, ALC_OUT_OF_MEMORY);

         value = alcDefaultAllDeviceSpecifier;
-        if(pDevice) ALCdevice_DecRef(pDevice);
+        if(Device) ALCdevice_DecRef(Device);
         break;

     case ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER:
         if(!alcCaptureDeviceList)
             ProbeCaptureDeviceList();

-        pDevice = VerifyDevice(pDevice);
+        Device = VerifyDevice(Device);

         free(alcCaptureDefaultDeviceSpecifier);
         alcCaptureDefaultDeviceSpecifier = strdup(alcCaptureDeviceList ?
                                                   alcCaptureDeviceList : "");
         if(!alcCaptureDefaultDeviceSpecifier)
-            alcSetError(pDevice, ALC_OUT_OF_MEMORY);
+            alcSetError(Device, ALC_OUT_OF_MEMORY);

         value = alcCaptureDefaultDeviceSpecifier;
-        if(pDevice) ALCdevice_DecRef(pDevice);
+        if(Device) ALCdevice_DecRef(Device);
         break;

     case ALC_EXTENSIONS:
-        if(!VerifyDevice(pDevice))
+        if(!VerifyDevice(Device))
             value = alcNoDeviceExtList;
         else
         {
             value = alcExtensionList;
-            ALCdevice_DecRef(pDevice);
+            ALCdevice_DecRef(Device);
         }
         break;

     default:
-        pDevice = VerifyDevice(pDevice);
-        alcSetError(pDevice, ALC_INVALID_ENUM);
-        if(pDevice) ALCdevice_DecRef(pDevice);
+        Device = VerifyDevice(Device);
+        alcSetError(Device, ALC_INVALID_ENUM);
+        if(Device) ALCdevice_DecRef(Device);
         break;
     }

@@ -2658,14 +2658,14 @@
  *
  * Close the specified Device
  */
-ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *pDevice)
+ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *Device)
 {
     ALCdevice *volatile*list;
     ALCcontext *ctx;

     LockLists();
     list = &DeviceList;
-    while(*list && *list != pDevice)
+    while(*list && *list != Device)
         list = &(*list)->next;

     if(!*list || (*list)->Type == Capture)
@@ -2678,18 +2678,18 @@
     *list = (*list)->next;
     UnlockLists();

-    while((ctx=pDevice->ContextList) != NULL)
+    while((ctx=Device->ContextList) != NULL)
     {
         WARN("Releasing context %p\n", ctx);
-        ReleaseContext(ctx, pDevice);
-    }
-    if((pDevice->Flags&DEVICE_RUNNING))
-        ALCdevice_StopPlayback(pDevice);
-    pDevice->Flags &= ~DEVICE_RUNNING;
-
-    ALCdevice_ClosePlayback(pDevice);
-
-    ALCdevice_DecRef(pDevice);
+        ReleaseContext(ctx, Device);
+    }
+    if((Device->Flags&DEVICE_RUNNING))
+        ALCdevice_StopPlayback(Device);
+    Device->Flags &= ~DEVICE_RUNNING;
+
+    ALCdevice_ClosePlayback(Device);
+
+    ALCdevice_DecRef(Device);

     return ALC_TRUE;
 }


size_t printf() test

size_t printf() test

error: pathspec 'test2/format/size_t.c' did not match any file(s) known to git

--- test2/format/size_t.c
+++ test2/format/size_t.c
@@ -0,0 +1,16 @@
+// RUN: %check %s
+
+int printf(const char *, ...)
+	__attribute((format(printf, 1, 2)));
+
+typedef unsigned long size_t;
+
+void f()
+{
+	printf("%zu\n", (size_t)0); // CHECK: !/warn/
+	printf("%zd\n", (size_t)0); // CHECK: !/warn/
+	printf("%zzzf", 5.2f); // CHECK: warning: unexpected printf modifier 'z' for %f
+
+	printf("%lu\n", (signed long)0); // CHECK: !/warn/
+	printf("%ld\n", (unsigned long)0); // CHECK: !/warn/
+}


done for the one-file version

done for the one-file version

--- dwmstatus.c
+++ dwmstatus.c
@@ -24,14 +24,13 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
-#include <stdbool.h>
 #include <alsa/asoundlib.h>
 #include <time.h>
 #include <dirent.h>  /* check directory for new files */

 #include <X11/Xlib.h>

-#define INTERVAL            10  /* seconds */
+#define INTERVAL            60  /* seconds */
 #define BATT_NOW            "/sys/class/power_supply/BAT1/charge_now"
 #define BATT_FULL           "/sys/class/power_supply/BAT1/charge_full"
 #define BATT_STATUS         "/sys/class/power_supply/BAT1/status"


I keep working on the SDL2 backend.

I keep working on the SDL2 backend.

--- minheadless/source/sqWindow-SDL2.c
+++ minheadless/source/sqWindow-SDL2.c
@@ -7,6 +7,10 @@
 #include "sqEventCommon.h"
 #include "sqWindow.h"
 #include "config.h"
+
+#if defined(__unix__) || defined(__APPLE__) || defined(__linux__)
+#include <signal.h>
+#endif

 extern int getSavedWindowSize();

@@ -120,6 +124,11 @@
 static void sqSDL2_initialize(void)
 {
     SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
+
+#if defined(__unix__) || defined(__APPLE__) || defined(__linux__)
+    signal(SIGINT, SIG_DFL);
+    signal(SIGTERM, SIG_DFL);
+#endif
 }

 static void sqSDL2_shutdown(void)
@@ -296,6 +305,7 @@
         sqEventUnion event;
         memset(&event, 0, sizeof(event));
         event.key.type = EventTypeKeyboard;
+        event.key.timeStamp = rawEvent->key.timestamp;
         event.key.pressCode = EventKeyDown;
         event.key.charCode = rawEvent->key.keysym.sym;
         event.key.utf32Code = character;
@@ -312,6 +322,7 @@
         sqEventUnion event;
         memset(&event, 0, sizeof(event));
         event.key.type = EventTypeKeyboard;
+        event.key.timeStamp = rawEvent->key.timestamp;
         event.key.pressCode = EventKeyChar;
         event.key.charCode = character;
         event.key.utf32Code = character;
@@ -332,6 +343,7 @@
     sqEventUnion event;
     memset(&event, 0, sizeof(event));
     event.key.type = EventTypeKeyboard;
+    event.key.timeStamp = rawEvent->key.timestamp;
     event.key.pressCode = EventKeyUp;
     event.key.charCode = convertKeySymToCharacter(rawEvent->key.keysym.sym);
     event.key.utf32Code = convertKeySymToCharacter(rawEvent->key.keysym.sym);
@@ -353,6 +365,7 @@
     sqEventUnion event;
     memset(&event, 0, sizeof(event));
     event.key.type = EventTypeKeyboard;
+    event.key.timeStamp = rawEvent->text.timestamp;
     event.key.pressCode = EventKeyChar;
     event.key.modifiers = modifiersState;

@@ -382,6 +395,7 @@
     sqEventUnion event;
     memset(&event, 0, sizeof(event));
     event.mouse.type = EventTypeMouse;
+    event.mouse.timeStamp = rawEvent->button.timestamp;
     event.mouse.x = mousePositionX = rawEvent->button.x;
     event.mouse.y = mousePositionY = rawEvent->button.y;
     event.mouse.buttons = buttonState;
@@ -403,6 +417,7 @@
     sqEventUnion event;
     memset(&event, 0, sizeof(event));
     event.mouse.type = EventTypeMouse;
+    event.mouse.timeStamp = rawEvent->button.timestamp;
     event.mouse.x = mousePositionX = rawEvent->button.x;
     event.mouse.y = mousePositionY = rawEvent->button.y;
     event.mouse.buttons = buttonState;
@@ -422,6 +437,7 @@
     sqEventUnion event;
     memset(&event, 0, sizeof(event));
     event.mouse.type = EventTypeMouse;
+    event.mouse.timeStamp = rawEvent->motion.timestamp;
     event.mouse.x = mousePositionX = rawEvent->motion.x;
     event.mouse.y = mousePositionY = rawEvent->motion.y;
     event.mouse.buttons = buttonState;
@@ -429,6 +445,48 @@
     recordLowImportanceEvent(&event);
 }

+static void handleWindowEvent(const SDL_Event *rawEvent)
+{
+    if(rawEvent->window.windowID != windowID)
+    {
+        recordSDLEvent(rawEvent);
+        return;
+    }
+
+    switch(rawEvent->window.event)
+    {
+    case SDL_WINDOWEVENT_CLOSE:
+        {
+            sqEventUnion event;
+            memset(&event, 0, sizeof(event));
+            event.window.type = EventTypeWindow;
+            event.window.timeStamp = rawEvent->window.timestamp;
+            event.window.action = WindowEventClose;
+            recordEvent(&event);
+        }
+        break;
+    case SDL_WINDOWEVENT_MOVED:
+    case SDL_WINDOWEVENT_SIZE_CHANGED:
+    case SDL_WINDOWEVENT_RESIZED:
+        {
+            sqEventUnion event;
+            SDL_Rect rect;
+            SDL_GetWindowPosition(window, &rect.x, &rect.y);
+            SDL_GetRendererOutputSize(windowRenderer, &rect.w, &rect.h);
+            memset(&event, 0, sizeof(event));
+            event.window.type = EventTypeWindow;
+            event.window.timeStamp = rawEvent->window.timestamp;
+            event.window.action = WindowEventMetricChange;
+            event.window.value1 = rect.x;
+            event.window.value2 = rect.y;
+            event.window.value3 = rect.x + rect.w;
+            event.window.value4 = rect.y + rect.h;
+            recordEvent(&event);
+        }
+        break;
+    }
+}
+
 static void handleEvent(const SDL_Event *event)
 {
     switch(event->type)
@@ -454,8 +512,8 @@
     case SDL_MOUSEWHEEL:
         handleMouseWheel(event);
         break;
-    case SDL_QUIT:
-        ioExit();
+    case SDL_WINDOWEVENT:
+        handleWindowEvent(event);
         break;
     default:
         /* Record the unhandled SDL events for the image. */
@@ -640,11 +698,20 @@

 static char* sqSDL2_getWindowLabel(void)
 {
-    return "";
-}
-
-static sqInt sqSDL2_setWindowLabelOfSize(void *lblIndex, sqInt sz)
-{
+    return (char*)SDL_GetWindowTitle(window);
+}
+
+static sqInt sqSDL2_setWindowLabelOfSize(void *lblIndex, sqInt size)
+{
+    char *buffer;
+
+    buffer = (char*)malloc(size + 1);
+    memcpy(buffer, lblIndex, size);
+    buffer[size] = 0;
+
+    SDL_SetWindowTitle(window, buffer);
+
+    free(buffer);
     return 0;
 }

@@ -652,8 +719,8 @@
 {
     int width = 0;
     int height = 0;
-    if(window)
-        SDL_GetWindowSize(window, &width, &height);
+    if(windowRenderer)
+        SDL_GetRendererOutputSize(windowRenderer, &width, &height);
     return width;
 }

@@ -661,8 +728,8 @@
 {
     int width = 0;
     int height = 0;
-    if(window)
-        SDL_GetWindowSize(window, &width, &height);
+    if(windowRenderer)
+        SDL_GetRendererOutputSize(windowRenderer, &width, &height);
     return height;
 }

@@ -743,19 +810,18 @@

 static double sqSDL2_screenScaleFactor(void)
 {
-    SDL_Rect bounds;
-    if(SDL_GetDisplayBounds(0, &bounds) != 0)
-    {
-        return 1.0;
-    }
-
-    return (double)bounds.w / (double)bounds.h;
+    return 1.0;
 }

 static sqInt sqSDL2_screenSize(void)
 {
-    int winSize = getSavedWindowSize();
-    return winSize;
+    int width;
+    int height;
+    if(!windowRenderer)
+        return getSavedWindowSize();
+
+    SDL_GetRendererOutputSize(windowRenderer, &width, &height);
+    return height | (width << 16);
 }

 static sqInt sqSDL2_screenDepth(void)
@@ -766,16 +832,40 @@
 /* Clipboard */
 static sqInt sqSDL2_clipboardSize(void)
 {
-    return 0;
+    if(!SDL_HasClipboardText())
+        return 0;
+
+    return strlen(SDL_GetClipboardText());
 }

 static sqInt sqSDL2_clipboardReadIntoAt(sqInt count, sqInt byteArrayIndex, sqInt startIndex)
 {
-    return 0;
+    sqInt clipSize;
+    char *clipboardText;
+
+    clipboardText = SDL_GetClipboardText();
+    if(!clipboardText)
+        clipboardText = "";
+
+    clipSize = count;
+    if(count < clipSize)
+        clipSize = count;
+
+    memcpy(pointerForOop(byteArrayIndex + startIndex), (void *)clipboardText, clipSize);
+    return clipSize;
 }

 static sqInt sqSDL2_clipboardWriteFromAt(sqInt count, sqInt byteArrayIndex, sqInt startIndex)
 {
+    char *buffer;
+
+    buffer = (char*)malloc(count + 1);
+    memcpy(buffer, pointerForOop(byteArrayIndex + startIndex), count);
+    buffer[count] = 0;
+
+    SDL_SetClipboardText(buffer);
+
+    free(buffer);
     return 0;
 }


Update a trace

Update a trace

--- Alc/ALc.c
+++ Alc/ALc.c
@@ -2888,7 +2888,7 @@

 #ifdef _DEBUG
     if(g_ulDeviceCount > 0)
-        AL_PRINT("exit(): closing %u Device%s\n", g_ulDeviceCount, (g_ulDeviceCount>1)?"s":"");
+        AL_PRINT("ReleaseALC(): closing %u Device%s\n", g_ulDeviceCount, (g_ulDeviceCount>1)?"s":"");
 #endif

     while(g_pDeviceList)


Fix asan finding in bio_addr

Fix asan finding in bio_addr

Running test_tfo_cli under asan yields
==166214==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60700000d57c at pc 0x03ffa004ed86 bp 0x03ffe2977e80 sp 0x03ffe2977668
READ of size 112 at 0x60700000d57c thread T0
    #0 0x3ffa004ed85 in memcpy (/lib64/libasan.so.8+0x4ed85)
    #1 0x3ff9f3615b7 in BIO_ADDR_dup crypto/bio/bio_addr.c:77
[...]
and fails the test.

Fix this by copying the right structure of the union.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>

Reviewed-by: Todd Short <0267f0ecbdb3e99cdfd94eb139bf30919fa04d2f@me.com>
Reviewed-by: Matt Caswell <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18979)

--- crypto/bio/bio_addr.c
+++ crypto/bio/bio_addr.c
@@ -74,7 +74,7 @@
     if (ap != NULL) {
         ret = BIO_ADDR_new();
         if (ret != NULL)
-            memcpy(ret, ap, sizeof(BIO_ADDR));
+            BIO_ADDR_make(ret, &ap->sa);
     }
     return ret;
 }


Shorten a warning

Shorten a warning

--- Alc/ALc.c
+++ Alc/ALc.c
@@ -1627,7 +1627,7 @@
     if(!device->Hrtf && (device->UpdateSize&3))
     {
         if((CPUCapFlags&CPU_CAP_SSE))
-            WARN("SSE performance is degraded with a non-multiple of 4 update size (%u)\n", device->UpdateSize);
+            WARN("SSE performs best with multiple of 4 update sizes (%u)\n", device->UpdateSize);
     }

     oldMode = SetMixerFPUMode();


Insert a comment: This is one of the few files in this directory that is actually used (even though it may not appear so at first sight).

--- crypto/des/ncbc_enc.c
+++ crypto/des/ncbc_enc.c
@@ -1,4 +1,9 @@
 /* crypto/des/ncbc_enc.c */
+/*
+ * #included by:
+ *    cbc_enc.c  (des_cbc_encrypt)
+ *    des_enc.c  (des_ncbc_encrypt)
+ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *


Apply dither separately from output

Apply dither separately from output

--- Alc/ALu.c
+++ Alc/ALu.c
@@ -142,11 +142,11 @@

 /* Prior to VS2013, MSVC lacks the round() family of functions. */
 #if defined(_MSC_VER) && _MSC_VER < 1800
-static long lroundf(float val)
-{
-    if(val < 0.0)
-        return fastf2i(ceilf(val-0.5f));
-    return fastf2i(floorf(val+0.5f));
+static float roundf(float val)
+{
+    if(val < 0.0f)
+        return ceilf(val-0.5f);
+    return floorf(val+0.5f);
 }
 #endif

@@ -1527,10 +1527,37 @@
 }

-/* NOTE: Non-dithered conversions have unused extra parameters. */
-static inline ALfloat aluF2F(ALfloat val, ...)
+static void ApplyDither(ALfloatBUFFERSIZE *restrict Samples, ALuint *dither_seed,
+                        const ALfloat quant_scale, const ALsizei SamplesToDo,
+                        const ALsizei numchans)
+{
+    const ALfloat invscale = 1.0f / quant_scale;
+    ALuint seed = *dither_seed;
+    ALsizei c, i;
+
+    /* Dithering. Step 1, generate whitenoise (uniform distribution of random
+     * values between -1 and +1). Step 2 is to add the noise to the samples,
+     * before rounding and after scaling up to the desired quantization depth.
+     */
+    for(c = 0;c < numchans;c++)
+    {
+        ALfloat *restrict samples = Samples[c];
+        for(i = 0;i < SamplesToDo;i++)
+        {
+            ALfloat val = samples[i] * quant_scale;
+            ALuint rng0 = dither_rng(&seed);
+            ALuint rng1 = dither_rng(&seed);
+            val += (ALfloat)(rng0*(1.0/UINT_MAX) - rng1*(1.0/UINT_MAX));
+            samples[i] = roundf(val) * invscale;
+        }
+    }
+    *dither_seed = seed;
+}
+
+
+static inline ALfloat aluF2F(ALfloat val)
 { return val; }
-static inline ALint aluF2I(ALfloat val, ...)
+static inline ALint aluF2I(ALfloat val)
 {
     /* Floats only have a 24-bit mantissa, so [-16777216, +16777216] is the max
      * integer range normalized floats can be safely converted to (a bit of the
@@ -1538,44 +1565,25 @@
      */
     return fastf2i(clampf(val*16777216.0f, -16777216.0f, 16777215.0f))<<7;
 }
-static inline ALshort aluF2S(ALfloat val, ...)
+static inline ALshort aluF2S(ALfloat val)
 { return fastf2i(clampf(val*32768.0f, -32768.0f, 32767.0f)); }
-static inline ALbyte aluF2B(ALfloat val, ...)
+static inline ALbyte aluF2B(ALfloat val)
 { return fastf2i(clampf(val*128.0f, -128.0f, 127.0f)); }
-
-/* Dithered conversion functions. Only applies to 8- and 16-bit output for now,
- * as 32-bit int and float are at the limits of the rendered sample depth. This
- * can change if the dithering bit depth becomes configurable (effectively
- * quantizing to a lower bit depth than the output is capable of).
- */
-static inline ALshort aluF2SDithered(ALfloat val, const ALfloat dither_val)
-{
-    val = val*32768.0f + dither_val;
-    return lroundf(clampf(val, -32768.0f, 32767.0f));
-}
-static inline ALbyte aluF2BDithered(ALfloat val, const ALfloat dither_val)
-{
-    val = val*128.0f + dither_val;
-    return lroundf(clampf(val, -128.0f, 127.0f));
-}

 /* Define unsigned output variations. */
 #define DECL_TEMPLATE(T, Name, func, O)                     \
-static inline T Name(ALfloat val, const ALfloat dither_val) \
-{ return func(val, dither_val)+O; }
+static inline T Name(ALfloat val)                           \
+{ return func(val)+O; }

 DECL_TEMPLATE(ALubyte, aluF2UB, aluF2B, 128)
 DECL_TEMPLATE(ALushort, aluF2US, aluF2S, 32768)
 DECL_TEMPLATE(ALuint, aluF2UI, aluF2I, 2147483648u)
-DECL_TEMPLATE(ALubyte, aluF2UBDithered, aluF2BDithered, 128)
-DECL_TEMPLATE(ALushort, aluF2USDithered, aluF2SDithered, 32768)

 #undef DECL_TEMPLATE

-#define DECL_TEMPLATE(T, D, func)                                             \
-static void Write##T##D(const ALfloatBUFFERSIZE *InBuffer, ALvoid *OutBuffer, \
-                        const ALfloat *restrict DitherValues,                 \
-                        ALsizei SamplesToDo, ALsizei numchans)                \
+#define DECL_TEMPLATE(T, func)                                                \
+static void Write##T(const ALfloatBUFFERSIZE *InBuffer, ALvoid *OutBuffer,    \
+                     ALsizei SamplesToDo, ALsizei numchans)                   \
 {                                                                             \
     ALsizei i, j;                                                             \
     for(j = 0;j < numchans;j++)                                               \
@@ -1584,22 +1592,17 @@
         T *restrict out = (T*)OutBuffer + j;                                  \
                                                                               \
         for(i = 0;i < SamplesToDo;i++)                                        \
-            out[i*numchans] = func(in[i], DitherValues[i]);                   \
+            out[i*numchans] = func(in[i]);                                    \
     }                                                                         \
 }

-DECL_TEMPLATE(ALfloat, /*no dither*/, aluF2F)
-DECL_TEMPLATE(ALuint, /*no dither*/, aluF2UI)
-DECL_TEMPLATE(ALint, /*no dither*/, aluF2I)
-DECL_TEMPLATE(ALushort, /*no dither*/, aluF2US)
-DECL_TEMPLATE(ALshort, /*no dither*/, aluF2S)
-DECL_TEMPLATE(ALubyte, /*no dither*/, aluF2UB)
-DECL_TEMPLATE(ALbyte, /*no dither*/, aluF2B)
-
-DECL_TEMPLATE(ALushort, _Dithered, aluF2USDithered)
-DECL_TEMPLATE(ALshort, _Dithered, aluF2SDithered)
-DECL_TEMPLATE(ALubyte, _Dithered, aluF2UBDithered)
-DECL_TEMPLATE(ALbyte, _Dithered, aluF2BDithered)
+DECL_TEMPLATE(ALfloat, aluF2F)
+DECL_TEMPLATE(ALuint, aluF2UI)
+DECL_TEMPLATE(ALint, aluF2I)
+DECL_TEMPLATE(ALushort, aluF2US)
+DECL_TEMPLATE(ALshort, aluF2S)
+DECL_TEMPLATE(ALubyte, aluF2UB)
+DECL_TEMPLATE(ALbyte, aluF2B)

 #undef DECL_TEMPLATE

@@ -1775,7 +1778,6 @@
             ALfloat (*OutBuffer)[BUFFERSIZE] = device->RealOut.Buffer;
             ALsizei OutChannels = device->RealOut.NumChannels;
             struct Compressor *Limiter = device->Limiter;
-            ALfloat *DitherValues;

             /* Use NFCtrlData for temp value storage. */
             ApplyDistanceComp(OutBuffer, device->ChannelDelay, device->NFCtrlData,
@@ -1784,78 +1786,46 @@
             if(Limiter)
                 ApplyCompression(Limiter, OutChannels, SamplesToDo, OutBuffer);

-            /* Dithering. Step 1, generate whitenoise (uniform distribution of
-             * random values between -1 and +1). Use NFCtrlData for random
-             * value storage. Step 2 is to add the noise to the samples, before
-             * rounding and after scaling up to the desired quantization depth,
-             * which occurs in the sample conversion stage.
+            /* Dither only applies to 8- and 16-bit output for now, as 32-bit
+             * int and float are at the limits of the rendered sample depth.
+             * This can change if the dithering bit depth becomes configurable
+             * (effectively quantizing to a lower bit depth than the output is
+             * capable of).
              */
-            if(!device->DitherEnabled)
-                memset(device->NFCtrlData, 0, SamplesToDo*sizeof(ALfloat));
-            else
-            {
-                ALuint dither_seed = device->DitherSeed;
-                ALsizei i;
-
-                for(i = 0;i < SamplesToDo;i++)
-                {
-                    ALuint rng0 = dither_rng(&dither_seed);
-                    ALuint rng1 = dither_rng(&dither_seed);
-                    device->NFCtrlData[i] = (ALfloat)(rng0*(1.0/UINT_MAX) - rng1*(1.0/UINT_MAX));
-                }
-                device->DitherSeed = dither_seed;
-            }
-            DitherValues = device->NFCtrlData;
-
-#define WRITE(T, D, a, b, c, d, e) do {                                       \
-    Write##T##D(SAFE_CONST(ALfloatBUFFERSIZE*,(a)), (b), (c), (d), (e));      \
-    buffer = (T*)buffer + (d)*(e);                                            \
+#define WRITE(T, a, b, c, d) do {                                             \
+    Write##T(SAFE_CONST(ALfloatBUFFERSIZE*,(a)), (b), (c), (d));              \
+    buffer = (T*)buffer + (c)*(d);                                            \
 } while(0)
             switch(device->FmtType)
             {
                 case DevFmtByte:
                     if(device->DitherEnabled)
-                        WRITE(ALbyte, _Dithered, OutBuffer, buffer, DitherValues,
-                              SamplesToDo, OutChannels);
-                    else
-                        WRITE(ALbyte, /*no dither*/, OutBuffer, buffer, DitherValues,
-                              SamplesToDo, OutChannels);
+                        ApplyDither(OutBuffer, &device->DitherSeed, 128.0f, SamplesToDo, OutChannels);
+                    WRITE(ALbyte, OutBuffer, buffer, SamplesToDo, OutChannels);
                     break;
                 case DevFmtUByte:
                     if(device->DitherEnabled)
-                        WRITE(ALubyte, _Dithered, OutBuffer, buffer, DitherValues,
-                              SamplesToDo, OutChannels);
-                    else
-                        WRITE(ALubyte, /*no dither*/, OutBuffer, buffer, DitherValues,
-                              SamplesToDo, OutChannels);
+                        ApplyDither(OutBuffer, &device->DitherSeed, 128.0f, SamplesToDo, OutChannels);
+                    WRITE(ALubyte, OutBuffer, buffer, SamplesToDo, OutChannels);
                     break;
                 case DevFmtShort:
                     if(device->DitherEnabled)
-                        WRITE(ALshort, _Dithered, OutBuffer, buffer, DitherValues,
-                              SamplesToDo, OutChannels);
-                    else
-                        WRITE(ALshort, /*no dither*/, OutBuffer, buffer, DitherValues,
-                              SamplesToDo, OutChannels);
+                        ApplyDither(OutBuffer, &device->DitherSeed, 32768.0f, SamplesToDo, OutChannels);
+                    WRITE(ALshort, OutBuffer, buffer, SamplesToDo, OutChannels);
                     break;
                 case DevFmtUShort:
                     if(device->DitherEnabled)
-                        WRITE(ALushort, _Dithered, OutBuffer, buffer, DitherValues,
-                              SamplesToDo, OutChannels);
-                    else
-                        WRITE(ALushort, /*no dither*/, OutBuffer, buffer, DitherValues,
-                              SamplesToDo, OutChannels);
+                        ApplyDither(OutBuffer, &device->DitherSeed, 32768.0f, SamplesToDo, OutChannels);
+                    WRITE(ALushort, OutBuffer, buffer, SamplesToDo, OutChannels);
                     break;
                 case DevFmtInt:
-                    WRITE(ALint, /*no dither*/, OutBuffer, buffer, DitherValues,
-                          SamplesToDo, OutChannels);
+                    WRITE(ALint, OutBuffer, buffer, SamplesToDo, OutChannels);
                     break;
                 case DevFmtUInt:
-                    WRITE(ALuint, /*no dither*/, OutBuffer, buffer, DitherValues,
-                          SamplesToDo, OutChannels);
+                    WRITE(ALuint, OutBuffer, buffer, SamplesToDo, OutChannels);
                     break;
                 case DevFmtFloat:
-                    WRITE(ALfloat, /*no dither*/, OutBuffer, buffer, DitherValues,
-                          SamplesToDo, OutChannels);
+                    WRITE(ALfloat, OutBuffer, buffer, SamplesToDo, OutChannels);
                     break;
             }
 #undef WRITE


Refactor the EVP_RAND code to make locking issues less likely

Reviewed-by: Matthias St. Pierre <1910231d24f125aceac7850dc92279eee8d52323@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/12321)

--- crypto/evp/evp_rand.c
+++ crypto/evp/evp_rand.c
@@ -339,30 +339,43 @@
     return ctx->meth;
 }

+static int evp_rand_get_ctx_params_locked(EVP_RAND_CTX *ctx,
+                                          OSSL_PARAM params[])
+{
+    return ctx->meth->get_ctx_params(ctx->data, params);
+}
+
 int EVP_RAND_get_ctx_params(EVP_RAND_CTX *ctx, OSSL_PARAM params[])
 {
     int res;

     if (!evp_rand_lock(ctx))
         return 0;
-    res = ctx->meth->get_ctx_params(ctx->data, params);
-    evp_rand_unlock(ctx);
-    return res;
+    res = evp_rand_get_ctx_params_locked(ctx, params);
+    evp_rand_unlock(ctx);
+    return res;
+}
+
+static int evp_rand_set_ctx_params_locked(EVP_RAND_CTX *ctx,
+                                          const OSSL_PARAM params[])
+{
+    /* Clear out the cache state because the values can change on a set */
+    ctx->strength = 0;
+    ctx->max_request = 0;
+
+    if (ctx->meth->set_ctx_params != NULL)
+        return ctx->meth->set_ctx_params(ctx->data, params);
+    return 1;
 }

 int EVP_RAND_set_ctx_params(EVP_RAND_CTX *ctx, const OSSL_PARAM params[])
 {
-    int res = 1;
-
-    if (ctx->meth->set_ctx_params != NULL) {
-        if (!evp_rand_lock(ctx))
-            return 0;
-        res = ctx->meth->set_ctx_params(ctx->data, params);
-        evp_rand_unlock(ctx);
-        /* Clear out the cache state because the values can change on a set */
-        ctx->strength = 0;
-        ctx->max_request = 0;
-    }
+    int res;
+
+    if (!evp_rand_lock(ctx))
+        return 0;
+    res = evp_rand_set_ctx_params_locked(ctx, params);
+    evp_rand_unlock(ctx);
     return res;
 }

@@ -380,7 +393,7 @@
 const OSSL_PARAM *EVP_RAND_settable_ctx_params(const EVP_RAND *rand)
 {
     return rand->settable_ctx_params == NULL ? NULL
-                                             :rand->settable_ctx_params();
+                                             : rand->settable_ctx_params();
 }

 void EVP_RAND_do_all_provided(OPENSSL_CTX *libctx,
@@ -400,6 +413,14 @@
         evp_names_do_all(rand->prov, rand->name_id, fn, data);
 }

+static int evp_rand_instantiate_locked
+    (EVP_RAND_CTX *ctx, unsigned int strength, int prediction_resistance,
+     const unsigned char *pstr, size_t pstr_len)
+{
+    return ctx->meth->instantiate(ctx->data, strength, prediction_resistance,
+                                  pstr, pstr_len);
+}
+
 int EVP_RAND_instantiate(EVP_RAND_CTX *ctx, unsigned int strength,
                          int prediction_resistance,
                          const unsigned char *pstr, size_t pstr_len)
@@ -408,10 +429,15 @@

     if (!evp_rand_lock(ctx))
         return 0;
-    res = ctx->meth->instantiate(ctx->data, strength, prediction_resistance,
-                                 pstr, pstr_len);
-    evp_rand_unlock(ctx);
-    return res;
+    res = evp_rand_instantiate_locked(ctx, strength, prediction_resistance,
+                                      pstr, pstr_len);
+    evp_rand_unlock(ctx);
+    return res;
+}
+
+static int evp_rand_uninstantiate_locked(EVP_RAND_CTX *ctx)
+{
+    return ctx->meth->uninstantiate(ctx->data);
 }

 int EVP_RAND_uninstantiate(EVP_RAND_CTX *ctx)
@@ -420,29 +446,28 @@

     if (!evp_rand_lock(ctx))
         return 0;
-    res = ctx->meth->uninstantiate(ctx->data);
-    evp_rand_unlock(ctx);
-    return res;
-}
-
-int EVP_RAND_generate(EVP_RAND_CTX *ctx, unsigned char *out, size_t outlen,
-                      unsigned int strength, int prediction_resistance,
-                      const unsigned char *addin, size_t addin_len)
+    res = evp_rand_uninstantiate_locked(ctx);
+    evp_rand_unlock(ctx);
+    return res;
+}
+
+static int evp_rand_generate_locked(EVP_RAND_CTX *ctx, unsigned char *out,
+                                    size_t outlen, unsigned int strength,
+                                    int prediction_resistance,
+                                    const unsigned char *addin,
+                                    size_t addin_len)
 {
     size_t chunk;
     OSSL_PARAM params[2];
-    int res = 0;
-
-    if (!evp_rand_lock(ctx))
-        return 0;
+
     if (ctx->max_request == 0) {
         params[0] = OSSL_PARAM_construct_size_t(OSSL_DRBG_PARAM_MAX_REQUEST,
                                                 &chunk);
         params[1] = OSSL_PARAM_construct_end();
-        /* Cannot call EVP_RAND_get_ctx_params() since we have the lock */
-        if (!ctx->meth->get_ctx_params(ctx->data, params) || chunk == 0) {
+        if (!evp_rand_get_ctx_params_locked(ctx, params)
+                || chunk == 0) {
             EVPerr(0, EVP_R_UNABLE_TO_GET_MAXIMUM_REQUEST_SIZE);
-            goto err;
+            return 0;
         }
         ctx->max_request = chunk;
     }
@@ -451,7 +476,7 @@
         if (!ctx->meth->generate(ctx->data, out, chunk, strength,
                                  prediction_resistance, addin, addin_len)) {
             EVPerr(0, EVP_R_GENERATE_ERROR);
-            goto err;
+            return 0;
         }
         /*
          * Prediction resistance is only relevant the first time around,
@@ -459,68 +484,119 @@
          */
         prediction_resistance = 0;
     }
-    res = 1;
-err:
-    evp_rand_unlock(ctx);
-    return res;
+    return 1;
+}
+
+int EVP_RAND_generate(EVP_RAND_CTX *ctx, unsigned char *out, size_t outlen,
+                      unsigned int strength, int prediction_resistance,
+                      const unsigned char *addin, size_t addin_len)
+{
+    int res;
+
+    if (!evp_rand_lock(ctx))
+        return 0;
+    res = evp_rand_generate_locked(ctx, out, outlen, strength,
+                                   prediction_resistance, addin, addin_len);
+    evp_rand_unlock(ctx);
+    return res;
+}
+
+static int evp_rand_reseed_locked(EVP_RAND_CTX *ctx, int prediction_resistance,
+                                  const unsigned char *ent, size_t ent_len,
+                                  const unsigned char *addin, size_t addin_len)
+{
+    if (ctx->meth->reseed != NULL)
+        return ctx->meth->reseed(ctx->data, prediction_resistance,
+                                 ent, ent_len, addin, addin_len);
+    return 1;
 }

 int EVP_RAND_reseed(EVP_RAND_CTX *ctx, int prediction_resistance,
                     const unsigned char *ent, size_t ent_len,
                     const unsigned char *addin, size_t addin_len)
 {
-    int res = 1;
-
-    if (!evp_rand_lock(ctx))
-        return 0;
-    if (ctx->meth->reseed != NULL)
-        res = ctx->meth->reseed(ctx->data, prediction_resistance,
-                                ent, ent_len, addin, addin_len);
-    evp_rand_unlock(ctx);
-    return res;
-}
-
-int EVP_RAND_nonce(EVP_RAND_CTX *ctx, unsigned char *out, size_t outlen)
-{
-    int res = 1;
-    unsigned int str = EVP_RAND_strength(ctx);
-
-    if (!evp_rand_lock(ctx))
-        return 0;
-    if (ctx->meth->nonce == NULL
-            || !ctx->meth->nonce(ctx->data, out, str, outlen, outlen))
-        res = ctx->meth->generate(ctx->data, out, outlen, str, 0, NULL, 0);
-    evp_rand_unlock(ctx);
-    return res;
-}
-
-unsigned int EVP_RAND_strength(EVP_RAND_CTX *ctx)
-{
-    OSSL_PARAM params[2];
-    int res;
+    int res;
+
+    if (!evp_rand_lock(ctx))
+        return 0;
+    res = evp_rand_reseed_locked(ctx, prediction_resistance,
+                                 ent, ent_len, addin, addin_len);
+    evp_rand_unlock(ctx);
+    return res;
+}
+
+static unsigned int evp_rand_strength_locked(EVP_RAND_CTX *ctx)
+{
+    OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END };

     if (ctx->strength == 0) {
         params[0] = OSSL_PARAM_construct_uint(OSSL_RAND_PARAM_STRENGTH,
                                               &ctx->strength);
-        params[1] = OSSL_PARAM_construct_end();
-        res = EVP_RAND_get_ctx_params(ctx, params);
-        if (!res)
+        if (!evp_rand_get_ctx_params_locked(ctx, params))
             return 0;
     }
     return ctx->strength;
 }

+unsigned int EVP_RAND_strength(EVP_RAND_CTX *ctx)
+{
+    unsigned int res;
+
+    if (!evp_rand_lock(ctx))
+        return 0;
+    res = evp_rand_strength_locked(ctx);
+    evp_rand_unlock(ctx);
+    return res;
+}
+
+static int evp_rand_nonce_locked(EVP_RAND_CTX *ctx, unsigned char *out,
+                                 size_t outlen)
+{
+    unsigned int str = evp_rand_strength_locked(ctx);
+
+    if (ctx->meth->nonce == NULL)
+        return 0;
+    if (ctx->meth->nonce(ctx->data, out, str, outlen, outlen))
+        return 1;
+    return evp_rand_generate_locked(ctx, out, outlen, str, 0, NULL, 0);
+}
+
+int EVP_RAND_nonce(EVP_RAND_CTX *ctx, unsigned char *out, size_t outlen)
+{
+    int res;
+
+    if (!evp_rand_lock(ctx))
+        return 0;
+    res = evp_rand_nonce_locked(ctx, out, outlen);
+    evp_rand_unlock(ctx);
+    return res;
+}
+
 int EVP_RAND_state(EVP_RAND_CTX *ctx)
 {
     OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END };
-    int status, res;
-
-    params[0] = OSSL_PARAM_construct_int(OSSL_RAND_PARAM_STATE,
-                                         &status);
-    res = EVP_RAND_get_ctx_params(ctx, params);
-    if (!res)
-        status = EVP_RAND_STATE_ERROR;
-    return status;
+    int state;
+
+    params[0] = OSSL_PARAM_construct_int(OSSL_RAND_PARAM_STATE, &state);
+    if (!EVP_RAND_get_ctx_params(ctx, params))
+        state = EVP_RAND_STATE_ERROR;
+    return state;
+}
+
+static int evp_rand_set_callbacks_locked(EVP_RAND_CTX *ctx,
+                                         OSSL_INOUT_CALLBACK *get_entropy,
+                                         OSSL_CALLBACK *cleanup_entropy,
+                                         OSSL_INOUT_CALLBACK *get_nonce,
+                                         OSSL_CALLBACK *cleanup_nonce,
+                                         void *arg)
+{
+    if (ctx->meth->set_callbacks == NULL) {
+        EVPerr(0, EVP_R_UNABLE_TO_SET_CALLBACKS);
+        return 0;
+    }
+    ctx->meth->set_callbacks(ctx->data, get_entropy, cleanup_entropy,
+                             get_nonce, cleanup_nonce, arg);
+    return 1;
 }

 int EVP_RAND_set_callbacks(EVP_RAND_CTX *ctx,
@@ -529,24 +605,30 @@
                            OSSL_INOUT_CALLBACK *get_nonce,
                            OSSL_CALLBACK *cleanup_nonce, void *arg)
 {
-    if (ctx->meth->set_callbacks == NULL) {
-        EVPerr(0, EVP_R_UNABLE_TO_SET_CALLBACKS);
-        return 0;
-    }
-    ctx->meth->set_callbacks(ctx->data, get_entropy, cleanup_entropy,
-                             get_nonce, cleanup_nonce, arg);
-    return 1;
+    int res;
+
+    if (!evp_rand_lock(ctx))
+        return 0;
+    res = evp_rand_set_callbacks_locked(ctx, get_entropy, cleanup_entropy,
+                                        get_nonce, cleanup_nonce, arg);
+    evp_rand_unlock(ctx);
+    return res;
+}
+
+static int evp_rand_verify_zeroization_locked(EVP_RAND_CTX *ctx)
+{
+    if (ctx->meth->verify_zeroization != NULL)
+        return ctx->meth->verify_zeroization(ctx->data);
+    return 0;
 }

 int EVP_RAND_verify_zeroization(EVP_RAND_CTX *ctx)
 {
-    int res = 0;
-
-    if (ctx->meth->verify_zeroization != NULL) {
-        if (!evp_rand_lock(ctx))
-            return 0;
-        res = ctx->meth->verify_zeroization(ctx->data);
-        evp_rand_unlock(ctx);
-    }
-    return res;
-}
+    int res;
+
+    if (!evp_rand_lock(ctx))
+        return 0;
+    res = evp_rand_verify_zeroization_locked(ctx);
+    evp_rand_unlock(ctx);
+    return res;
+}


Check buffer size when copying padding instead of the data pointer

--- Alc/ALu.c
+++ Alc/ALu.c
@@ -1025,7 +1025,7 @@
         if(BufferListItem->next)
         {
             ALbuffer *NextBuf = BufferListItem->next->buffer;
-            if(NextBuf && NextBuf->data)
+            if(NextBuf && NextBuf->size)
             {
                 ALint ulExtraSamples = BUFFER_PADDING*Channels*Bytes;
                 ulExtraSamples = min(NextBuf->size, ulExtraSamples);
@@ -1035,7 +1035,7 @@
         else if(ALSource->bLooping)
         {
             ALbuffer *NextBuf = ALSource->queue->buffer;
-            if(NextBuf && NextBuf->data)
+            if(NextBuf && NextBuf->size)
             {
                 ALint ulExtraSamples = BUFFER_PADDING*Channels*Bytes;
                 ulExtraSamples = min(NextBuf->size, ulExtraSamples);


reformat evp_test.c

reformat evp_test.c

Reviewed-by: Matt Caswell <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@openssl.org>

--- crypto/evp/evp_test.c
+++ crypto/evp/evp_test.c
@@ -333,12 +333,12 @@
 static void free_key_list(struct key_list *lst)
 {
     while (lst != NULL) {
-	struct key_list *ltmp;
+        struct key_list *ltmp;
         EVP_PKEY_free(lst->key);
         OPENSSL_free(lst->name);
-	ltmp = lst->next;
-	OPENSSL_free(lst);
-	lst = ltmp;
+        ltmp = lst->next;
+        OPENSSL_free(lst);
+        lst = ltmp;
     }
 }

@@ -346,7 +346,7 @@
 {
     long err = ERR_peek_error();
     if (ERR_GET_LIB(err) == ERR_LIB_EVP
-         && ERR_GET_REASON(err) == EVP_R_UNSUPPORTED_ALGORITHM) {
+        && ERR_GET_REASON(err) == EVP_R_UNSUPPORTED_ALGORITHM) {
         ERR_clear_error();
         return 1;
     }
@@ -483,7 +483,7 @@
     ERR_load_crypto_strings();
     OpenSSL_add_all_algorithms();

-    memset(&t,0,sizeof(t));
+    memset(&t, 0, sizeof(t));
     t.meth = NULL;
     t.public = NULL;
     t.private = NULL;
@@ -769,7 +769,7 @@
         }
         if (tag || cdat->aead != EVP_CIPH_GCM_MODE) {
             if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,
-                                        cdat->tag_len, tag))
+                                     cdat->tag_len, tag))
                 goto err;
         }
     }
@@ -784,8 +784,8 @@
     if (!enc && cdat->aead == EVP_CIPH_OCB_MODE) {
         if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,
                                  cdat->tag_len, cdat->tag)) {
-                err = "TAG_SET_ERROR";
-                goto err;
+            err = "TAG_SET_ERROR";
+            goto err;
         }
     }


ArmVirtPkg/PlatformBootManagerLib: return to "-kernel before boot devices"

Move the TryRunningQemuKernel() call back to its original place. This
improves the UEFI boot time for VMs that have "-kernel", many disks or
NICs, and no "bootindex" properties. A well-known example is
guestfish/libguestfs.

For more info on the TryRunningQemuKernel() location, see the following
commits: 23d04b58e27b, a78c4836ea0b, 158990b941e4.

Cc: Ard Biesheuvel <66d3c5fdaeea7ff1f996ad04f2c45e08ab38e2f5@linaro.org>
Cc: Xiang Zheng <5af816d6521acd775e9509bdc9f9cc4d6ff0d56f@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <7437296077edea1cb64451c122c4dac071f0cfbc@redhat.com>
Tested-by: Richard W.M. Jones <d9c0c1814229c9d7f78a7e860ff9791c82a22dba@redhat.com>
Reviewed-by: Ard Biesheuvel <66d3c5fdaeea7ff1f996ad04f2c45e08ab38e2f5@linaro.org>

--- ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
+++ ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
@@ -671,6 +671,14 @@
   BootLogoEnableLogo ();

   //
+  // Process QEMU's -kernel command line option. The kernel booted this way
+  // will receive ACPI tables: in PlatformBootManagerBeforeConsole(), we
+  // connected any and all PCI root bridges, and then signaled the ACPI
+  // platform driver.
+  //
+  TryRunningQemuKernel ();
+
+  //
   // Connect the purported boot devices.
   //
   Status = ConnectDevicesFromQemu ();
@@ -680,14 +688,6 @@
     //
     EfiBootManagerConnectAll ();
   }
-
-  //
-  // Process QEMU's -kernel command line option. Note that the kernel booted
-  // this way should receive ACPI tables, which is why we connect all devices
-  // first (see above) -- PCI enumeration blocks ACPI table installation, if
-  // there is a PCI host.
-  //
-  TryRunningQemuKernel ();

   //
   // Enumerate all possible boot options, then filter and reorder them based on


sparse array: reduces the block size

sparse array: reduces the block size

This becomes a performance improvement in the ossl_sa_doall_arg function which
has started appearing on profile output.  The other ossl_sa_ functions don't
contribute significantly to profile output.

Reviewed-by: Matt Caswell <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@openssl.org>
Reviewed-by: Tomas Mraz <2bc6038c3dfca09b2da23c8b6da8ba884dc2dcc2@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17973)

--- crypto/sparse_array.c
+++ crypto/sparse_array.c
@@ -19,24 +19,19 @@
  * depth of the tree but potentially wastes more memory.  That is, this is a
  * direct space versus time tradeoff.
  *
- * The large memory model uses twelve bits which means that the are 4096
- * pointers in each tree node.  This is more than sufficient to hold the
- * largest defined NID (as of Feb 2019).  This means that using a NID to
- * index a sparse array becomes a constant time single array look up.
- *
- * The small memory model uses four bits which means the tree nodes contain
- * sixteen pointers.  This reduces the amount of unused space significantly
- * at a cost in time.
+ * The default is to use four bits which means that the are 16
+ * pointers in each tree node.
  *
  * The library builder is also permitted to define other sizes in the closed
- * interval [2, sizeof(ossl_uintmax_t) * 8].
+ * interval [2, sizeof(ossl_uintmax_t) * 8].  Space use generally scales
+ * exponentially with the block size, although the implementation only
+ * creates enough blocks to support the largest used index.  The depth is:
+ *      ceil(log_2(largest index) / 2^{block size})
+ * E.g. with a block size of 4, and a largest index of 1000, the depth
+ * will be three.
  */
 #ifndef OPENSSL_SA_BLOCK_BITS
-# ifdef OPENSSL_SMALL_FOOTPRINT
-#  define OPENSSL_SA_BLOCK_BITS           4
-# else
-#  define OPENSSL_SA_BLOCK_BITS           12
-# endif
+# define OPENSSL_SA_BLOCK_BITS           4
 #elif OPENSSL_SA_BLOCK_BITS < 2 || OPENSSL_SA_BLOCK_BITS > (BN_BITS2 - 1)
 # error OPENSSL_SA_BLOCK_BITS is out of range
 #endif


Return actual error code in failure state

--- crypto_scrypt-nosse.c
+++ crypto_scrypt-nosse.c
@@ -227,7 +227,7 @@
  * must satisfy r * p < 2^30 and buflen <= (2^32 - 1) * 32.  The parameter N
  * must be a power of 2 greater than 1.
  *
- * Return 0 on success; or -1 on error.
+ * Return 0 on success; or error code defined by errno.h.
  */
 int
 libscrypt_scrypt(const uint8_t * passwd, size_t passwdlen,
@@ -337,5 +337,5 @@
 	free(B0);
 err0:
 	/* Failure! */
-	return (-1);
-}
+	return (errno);
+}


time uit API urll

time uit API urll

--- DataLogger/readp1.c
+++ DataLogger/readp1.c
@@ -104,7 +104,7 @@
 {
 	printf_debug(" readp1_decode ");
 	const char *mysql_statement_base = "INSERT INTO ElectricityP1 (MeasurementTimeStamp,TotalkWhTarif1,TotalkWhTarif2,CurrentTarif,CurrentUsagekWatt,CurrentUsageL1A,CurrentUsageL2A,CurrentUsageL3A,CurrentUsageL1kWatt,CurrentUsageL2kWatt,CurrentUsageL3kWatt) VALUES ('%s',%f,%f,%d,%f,%d,%d,%d,%f,%f,%f);";
-	const char *json_base = "time=%s&json={TotalkWhTarif1:%f,TotalkWhTarif2:%f,CurrentTarif:%d,CurrentUsagekWatt:%f,CurrentUsageL1kWatt:%f,CurrentUsageL2kWatt:%f,CurrentUsageL3kWatt:%f}";
+	const char *json_base = /*"time=%s&*/"json={TotalkWhTarif1:%f,TotalkWhTarif2:%f,CurrentTarif:%d,CurrentUsagekWatt:%f,CurrentUsageL1kWatt:%f,CurrentUsageL2kWatt:%f,CurrentUsageL3kWatt:%f}";
 	char *mysql_statement = malloc ( 1024*sizeof(char) );
 	char *json_string = malloc ( 1024*sizeof(char) );
 	int curposition = 0;
@@ -160,7 +160,7 @@
 	double CurrentUsageL3Watt = readp1_double_withunit(line);

 	sprintf( mysql_statement, mysql_statement_base, MeasurementTimeStamp,TotalkWhTarif1,TotalkWhTarif2,CurrentTarif,CurrentUsageWatt,CurrentUsageL1A,CurrentUsageL2A,CurrentUsageL3A,CurrentUsageL1Watt,CurrentUsageL2Watt,CurrentUsageL3Watt);
-	sprintf( json_string, json_base, MeasurementTimeStamp,TotalkWhTarif1,TotalkWhTarif2,CurrentTarif,CurrentUsageWatt,CurrentUsageL1Watt,CurrentUsageL2Watt,CurrentUsageL3Watt);
+	sprintf( json_string, json_base, /*MeasurementTimeStamp,*/TotalkWhTarif1,TotalkWhTarif2,CurrentTarif,CurrentUsageWatt,CurrentUsageL1Watt,CurrentUsageL2Watt,CurrentUsageL3Watt);

 	printf_debug("readp1:mysql_statement=%s\n\r",mysql_statement);
 	printf_debug("readp1:json_string=%s\n\r",json_string);


Rename Quad to Quadraphonic

Rename Quad to Quadraphonic

--- Alc/ALc.c
+++ Alc/ALc.c
@@ -865,7 +865,7 @@
     {
     case DevFmtMono: return "Mono";
     case DevFmtStereo: return "Stereo";
-    case DevFmtQuad: return "Quad";
+    case DevFmtQuad: return "Quadraphonic";
     case DevFmtX51: return "5.1 Surround";
     case DevFmtX61: return "6.1 Surround";
     case DevFmtX71: return "7.1 Surround";


Give "OpenAL Soft" for the standard device name

--- Alc/ALc.c
+++ Alc/ALc.c
@@ -1857,18 +1857,20 @@
         break;

     case ALC_DEVICE_SPECIFIER:
-        if(!VerifyDevice(pDevice))
-            value = alcDefaultName;
-        else
+        value = alcDefaultName;
+        break;
+
+    case ALC_ALL_DEVICES_SPECIFIER:
+        if(VerifyDevice(pDevice))
         {
             value = pDevice->szDeviceName;
             ALCdevice_DecRef(pDevice);
         }
-        break;
-
-    case ALC_ALL_DEVICES_SPECIFIER:
-        ProbeAllDeviceList();
-        value = alcAllDeviceList;
+        else
+        {
+            ProbeAllDeviceList();
+            value = alcAllDeviceList;
+        }
         break;

     case ALC_CAPTURE_DEVICE_SPECIFIER:


Fix log message in feldspar_array.h

Fix log message in feldspar_array.h

--- lib/Feldspar/C/feldspar_array.h
+++ lib/Feldspar/C/feldspar_array.h
@@ -104,7 +104,7 @@
         // First initialization
         arr->bytes = newBytes;
         arr->buffer = (void*)malloc( newBytes );
-        log_5("initArray %p - alloc %d * %d bytes %d at %p\n"
+        log_5("initArray %p - alloc %d * %d = %d bytes at %p\n"
              , arr, arr->length, arr->elemSize, newBytes, arr->buffer);
         arr->inited = INITED;
     }


Return the new vector result from aluMatrixVector

--- Alc/ALu.c
+++ Alc/ALu.c
@@ -162,14 +162,14 @@
     vec[2] = v.v[0]*mtx->m[0][2] + v.v[1]*mtx->m[1][2] + v.v[2]*mtx->m[2][2] + v.v[3]*mtx->m[3][2];
 }

-static inline ALvoid aluMatrixVector(aluVector *vec, const aluMatrix *mtx)
-{
-    aluVector v = *vec;
-
-    vec->v[0] = v.v[0]*mtx->m[0][0] + v.v[1]*mtx->m[1][0] + v.v[2]*mtx->m[2][0] + v.v[3]*mtx->m[3][0];
-    vec->v[1] = v.v[0]*mtx->m[0][1] + v.v[1]*mtx->m[1][1] + v.v[2]*mtx->m[2][1] + v.v[3]*mtx->m[3][1];
-    vec->v[2] = v.v[0]*mtx->m[0][2] + v.v[1]*mtx->m[1][2] + v.v[2]*mtx->m[2][2] + v.v[3]*mtx->m[3][2];
-    vec->v[3] = v.v[0]*mtx->m[0][3] + v.v[1]*mtx->m[1][3] + v.v[2]*mtx->m[2][3] + v.v[3]*mtx->m[3][3];
+static inline aluVector aluMatrixVector(const aluMatrix *mtx, const aluVector *vec)
+{
+    aluVector v;
+    v.v[0] = vec->v[0]*mtx->m[0][0] + vec->v[1]*mtx->m[1][0] + vec->v[2]*mtx->m[2][0] + vec->v[3]*mtx->m[3][0];
+    v.v[1] = vec->v[0]*mtx->m[0][1] + vec->v[1]*mtx->m[1][1] + vec->v[2]*mtx->m[2][1] + vec->v[3]*mtx->m[3][1];
+    v.v[2] = vec->v[0]*mtx->m[0][2] + vec->v[1]*mtx->m[1][2] + vec->v[2]*mtx->m[2][2] + vec->v[3]*mtx->m[3][2];
+    v.v[3] = vec->v[0]*mtx->m[0][3] + vec->v[1]*mtx->m[1][3] + vec->v[2]*mtx->m[2][3] + vec->v[3]*mtx->m[3][3];
+    return v;
 }

@@ -295,12 +295,10 @@
         0.0f, 0.0f,  0.0f, 1.0f
     );

-    P = Listener->Position;
-    aluMatrixVector(&P, &Listener->Params.Matrix);
+    P = aluMatrixVector(&Listener->Params.Matrix, &Listener->Position);
     aluMatrixSetRow(&Listener->Params.Matrix, 3, -P.v[0], -P.v[1], -P.v[2], 1.0f);

-    Listener->Params.Velocity = Listener->Velocity;
-    aluMatrixVector(&Listener->Params.Velocity, &Listener->Params.Matrix);
+    Listener->Params.Velocity = aluMatrixVector(&Listener->Params.Matrix, &Listener->Velocity);
 }

 ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCcontext *ALContext)
@@ -790,9 +788,9 @@
     {
         const aluMatrix *Matrix = &ALContext->Listener->Params.Matrix;
         /* Transform source vectors */
-        aluMatrixVector(&Position, Matrix);
-        aluMatrixVector(&Velocity, Matrix);
-        aluMatrixVector(&Direction, Matrix);
+        Position = aluMatrixVector(Matrix, &Position);
+        Velocity = aluMatrixVector(Matrix, &Velocity);
+        Direction = aluMatrixVector(Matrix, &Direction);
     }
     else
     {


Fixed formatting and switched to proper casting not functions

--- Average.h
+++ Average.h
@@ -95,8 +95,7 @@
 template <class T> void Average<T>::push(T entry) {
     if (_count < _size) {                                     // adding new values to array
         _count++;                                             // count number of values in array
-    }
-    else {                                                    // overwriting old values
+    } else {                                                    // overwriting old values
         _sum = _sum -_store[_position];                       // remove old value from _sum
     }
     _store[_position] = entry;                                // store new value in array
@@ -115,7 +114,7 @@
     if (_count == 0) {
         return 0;
     }
-    return (float(_sum) / (float)_count);                     // mean calculation based on _sum
+    return ((float)_sum / (float)_count);                     // mean calculation based on _sum
 }

 template <class T> T Average<T>::mode() {


Use the new BATgroup to create the groups in BATsubsort.


  * Added test code of the <img align="center"> attribute for SoftBank HTML converter.

git-svn-id: 4ec3457f076cc669589aef85c1dfbed86f312c92@2485 1a406e8e-add9-4483-a2c8-d8cac5b7c224

--- test/chxj_jhtml/test_chxj_jhtml.c
+++ test/chxj_jhtml/test_chxj_jhtml.c
@@ -226,6 +226,7 @@
 void test_jhtml_img_tag_011();
 void test_jhtml_img_tag_012();
 void test_jhtml_img_tag_013();
+void test_jhtml_img_tag_013_1();
 void test_jhtml_img_tag_014();
 void test_jhtml_img_tag_015();
 void test_jhtml_img_tag_016();
@@ -721,6 +722,7 @@
   CU_add_test(jhtml_suite, "test  with value(bottom)." ,             test_jhtml_img_tag_011);
   CU_add_test(jhtml_suite, "test  with value(left)." ,               test_jhtml_img_tag_012);
   CU_add_test(jhtml_suite, "test  with value(right)." ,              test_jhtml_img_tag_013);
+  CU_add_test(jhtml_suite, "test  with value(center)." ,             test_jhtml_img_tag_013_1);
   CU_add_test(jhtml_suite, "test  with value(unkown)." ,             test_jhtml_img_tag_014);
   CU_add_test(jhtml_suite, "test  with no value." ,                  test_jhtml_img_tag_015);
   CU_add_test(jhtml_suite, "test  with void value." ,                test_jhtml_img_tag_016);
@@ -6148,6 +6150,36 @@
 #undef TEST_STRING
 #undef RESULT_STRING
 }
+void test_jhtml_img_tag_013_1()
+{
+#define  TEST_STRING ""
+#define  RESULT_STRING ""
+  char  *ret;
+  char  *tmp;
+  device_table spec;
+  chxjconvrule_entry entry;
+  cookie_t cookie;
+  apr_size_t destlen;
+  APR_INIT;
+
+  COOKIE_INIT(cookie);
+
+  SPEC_INIT(spec);
+  destlen = sizeof(TEST_STRING)-1;
+
+  tmp = chxj_encoding(&r, TEST_STRING, &destlen);
+  ret = chxj_convert_jhtml(&r, &spec, tmp, destlen, &destlen, &entry, &cookie);
+  ret = chxj_rencoding(&r, ret, &destlen);
+  fprintf(stderr, "actual:[%s]\n", ret);
+  fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+  CU_ASSERT(ret != NULL);
+  CU_ASSERT(strcmp(RESULT_STRING, ret) == 0);
+  CU_ASSERT(destlen == sizeof(RESULT_STRING)-1);
+
+  APR_TERM;
+#undef TEST_STRING
+#undef RESULT_STRING
+}
 void test_jhtml_img_tag_014()
 {
 #define  TEST_STRING ""


Hold global lock during mixing only when iterating device contexts

--- Alc/ALu.c
+++ Alc/ALu.c
@@ -1247,8 +1247,6 @@
     int fpuState;
     ALuint i, c;

-    SuspendContext(NULL);
-
 #if defined(HAVE_FESETROUND)
     fpuState = fegetround();
     fesetround(FE_TOWARDZERO);
@@ -1268,6 +1266,7 @@
         /* Clear mixing buffer */
         memset(DryBuffer, 0, SamplesToDo*OUTPUTCHANNELS*sizeof(ALfloat));

+        SuspendContext(NULL);
         for(c = 0;c < device->NumContexts;c++)
         {
             ALContext = device->Contexts[c];
@@ -1288,6 +1287,7 @@
             }
             ProcessContext(ALContext);
         }
+        ProcessContext(NULL);

         //Post processing loop
         ChanMap = device->DevChannels;
@@ -1396,8 +1396,6 @@
 #elif defined(HAVE__CONTROLFP)
     _controlfp(fpuState, 0xfffff);
 #endif
-
-    ProcessContext(NULL);
 }

 ALvoid aluHandleDisconnect(ALCdevice *device)


removed countour rendering used for debugging

--- previewer/projector.c
+++ previewer/projector.c
@@ -167,12 +167,6 @@
     SDL_Rect r;
     r.x = x1+1; r.w = x2-x1-1;
     r.y = y;  r.h = 1;
-    uint8_t R, g, b, a;
-    SDL_GetRenderDrawColor(renderer, &R, &g, &b, &a);
-    SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
-    SDL_RenderDrawPoint(renderer, x1, y);
-    SDL_RenderDrawPoint(renderer, x2, y);
-    SDL_SetRenderDrawColor(renderer, R, g, b, a);
     SDL_RenderFillRect(renderer, &r);
 }


tests/xchownx.c: use errno2name

tests/xchownx.c: use errno2name

--- tests/xchownx.c
+++ tests/xchownx.c
@@ -54,13 +54,11 @@
 #ifdef ACCESS_BY_DESCRIPTOR
 # define SYSCALL_ARG1 fd
 # define FMT_ARG1 "%d"
-# define ERRNO_STR "EBADF"
 # define EOK_CMD CLOSE_SAMPLE
 # define CLEANUP_CMD UNLINK_SAMPLE
 #else
 # define SYSCALL_ARG1 sample
 # define FMT_ARG1 "\"%s\""
-# define ERRNO_STR "ENOENT"
 # define EOK_CMD UNLINK_SAMPLE
 # define CLEANUP_CMD CLOSE_SAMPLE
 #endif
@@ -163,7 +161,7 @@
 		print_int(gnum);
 		errno = saved_errno;
 		if (expected)
-			printf(") = %ld " ERRNO_STR " (%m)\n", expected);
+			printf(") = %ld %s (%m)\n", expected, errno2name());
 		else
 			printf(") = 0\n");
 	}


remove orphaned OgreOSXCocoaTouchView.h

remove orphaned OgreOSXCocoaTouchView.h

--- OgreMain/include/iOS/OgreOSXCocoaTouchView.h
+++ OgreMain/include/iOS/OgreOSXCocoaTouchView.h
@@ -1,55 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2014 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
-#ifndef __OSXCocoaView_H__
-#define __OSXCocoaView_H__
-
-#include "OgreRenderWindow.h"
-#include <UIKit/UIKit.h>
-
-@interface OgreView : UIView
-{
-    Ogre::RenderWindow *window;
-}
-
-- (id)initWithFrame:(CGRect)f;
-- (id)initWithGLiPhoneWindow:(Ogre::RenderWindow*)w;
-
-- (void)setOgreWindow:(Ogre::RenderWindow*)w;
-- (Ogre::RenderWindow*)ogreWindow;
-
-- (void)setFrameSize:(CGSize)s;
-
-@end
-
-@interface OgreWindow : UIWindow
-{}
-@end
-
-#endif
-


generated code with 0<D<norm([D1,D2])

generated code with 0<D<norm([D1,D2])

git-svn-id: de9bbed4c30e0eb58fe8e7d66f5c80b71699a07c@2140 bf01a9d7-0df3-0310-8ad4-b1c94d9ae2d5

--- Numerics/src/NonSmoothSolvers/FrictionContact/FrictionContact3D_globalAlartCurnier.c
+++ Numerics/src/NonSmoothSolvers/FrictionContact/FrictionContact3D_globalAlartCurnier.c
@@ -38,11 +38,10 @@
   double* x1 = ++x;
   double* x2 = ++x;

-  //  double* r11 = r+_11;
-  //double* r12 = r+_12;
-  //double* r21 = r+_21;
-  //double* r22 = r+_22;
-  SET3X3(r);
+  double* r11 = r + _11;
+  double* r12 = r + _12;
+  double* r21 = r + _21;
+  double* r22 = r + _22;

   double invp_, p_, p3;

@@ -79,27 +78,85 @@
 {
   assert(result);

-  double x0 = rhon * un;
-  double x1 = rn - x0;
-  double x4 = rhot1 * ut1;
-  double x5 = rt1 - x4;
-  double x6 = mu * x1;
-  double x7 = rhot2 * ut2;
-  double x8 = rt2 - x7;
-  double x9 = pow(x8, 2);
-  double x10 = pow(x5, 2);
-  double x11 = x10 + x9;
-  double x12 = pow(x11, (1.0 / 2.0));
-  double x16 = 1.0 / x12;
-  double x19 = pow(x16, 3);
-  double x20 = x4 - rt1;
-  double x22 = x7 - rt2;
-  double x23 = mu * x1 * x16;
+
+  double x0;
+  double x1;
+  double x2;
+  double x3;
+  double x4;
+  double x5;
+  double x6;
+  double x7;
+  double x8;
+  double x9;
+  double x10;
+  double x11;
+  double x12;
+  double x13;
+  double x14;
+  double x15;
+  double x16;
+  double x17;
+  double x18;
+  double x19;
+  double x20;
+  double x21;
+  double x22;
+  double x23;
+  double x24;
+  x0 = rhon * un;
+  x1 = rn - x0;
+  x2 = x1 < 0;
+  x3 = 0 <= x1;
+  x4 = rhot1 * ut1;
+  x5 = rt1 - x4;
+  x6 = rhot2 * ut2;
+  x7 = rt2 - x6;
+  x8 = pow(x7, 2);
+  x9 = pow(x5, 2);
+  x10 = x8 + x9;
+  x11 = mu * x1;
+  x12 = pow(x10, (1.0 / 2.0));
+  x13 = x12 <= x11;
+  x14 = 1.0 / x12;
+  x15 = x11 < x12;
+  x16 = 0 < x11;
+  x17 = x11 <= 0;
+  x18 = (0, x11 <= 0);
+  x19 = (0, x12 <= x11);
+  x20 = pow(x14, 3);
+  x21 = x4 - rt1;
+  x22 = (1, x12 <= x11);
+  x23 = x6 - rt2;
+  x24 = x11 * x14;
   result[6] = 0;
   result[9] = 0;
   result[15] = 0;
   result[18] = 0;
-  if (x12 <= x6)
+  if ((0 < x11) && (x11 < x12))
+  {
+    result[1] = -rt1 + x24 * x5;
+    result[4] = mu * rhon * x14 * x5;
+    result[7] = rhot1 * x24 - rhot1 * x11 * x20 * x9;
+    result[10] = -rhot2 * x11 * x20 * x5 * x7;
+    result[13] = -mu * x14 * x5;
+    result[16] = 1 - x24 - mu * x1 * x20 * x21 * x5;
+    result[19] = -mu * x1 * x20 * x23 * x5;
+    result[2] = -rt2 + x24 * x7;
+    result[5] = mu * rhon * x14 * x7;
+    result[8] = -rhot1 * x11 * x20 * x5 * x7;
+    result[11] = rhot2 * x24 - rhot2 * x11 * x20 * x8;
+    result[14] = -mu * x14 * x7;
+    result[17] = -mu * x1 * x20 * x21 * x7;
+    result[20] = 1 - x24 - mu * x1 * x20 * x23 * x7;
+  };
+  if (0 <= x1)
+  {
+    result[0] = -x0;
+    result[3] = rhon;
+    result[12] = 0;
+  };
+  if ((0 < x11) && (x12 <= x11))
   {
     result[1] = x5 - rt1;
     result[4] = 0;
@@ -108,7 +165,7 @@
     result[13] = 0;
     result[16] = 0;
     result[19] = 0;
-    result[2] = x8 - rt2;
+    result[2] = x7 - rt2;
     result[5] = 0;
     result[8] = 0;
     result[11] = rhot2;
@@ -116,30 +173,7 @@
     result[17] = 0;
     result[20] = 0;
   };
-  if (x1 < 0)
-  {
-    result[0] = -rn;
-    result[3] = 0;
-    result[12] = 1;
-  };
-  if (x6 < x12)
-  {
-    result[1] = -rt1 + x23 * x5;
-    result[4] = mu * rhon * x16 * x5;
-    result[7] = rhot1 * x23 - mu * rhot1 * x1 * x10 * x19;
-    result[10] = -mu * rhot2 * x1 * x19 * x5 * x8;
-    result[13] = -mu * x16 * x5;
-    result[16] = 1 - x23 - mu * x1 * x19 * x20 * x5;
-    result[19] = -mu * x1 * x19 * x22 * x5;
-    result[2] = -rt2 + x23 * x8;
-    result[5] = mu * rhon * x16 * x8;
-    result[8] = -mu * rhot1 * x1 * x19 * x5 * x8;
-    result[11] = rhot2 * x23 - mu * rhot2 * x1 * x19 * x9;
-    result[14] = -mu * x16 * x8;
-    result[17] = -mu * x1 * x19 * x20 * x8;
-    result[20] = 1 - x23 - mu * x1 * x19 * x22 * x8;
-  };
-  if (x6 <= 0)
+  if (x11 <= 0)
   {
     result[1] = -rt1;
     result[4] = 0;
@@ -156,11 +190,11 @@
     result[17] = 0;
     result[20] = 1;
   };
-  if (0 <= x1)
-  {
-    result[0] = -x0;
-    result[3] = rhon;
-    result[12] = 0;
+  if (x1 < 0)
+  {
+    result[0] = -rn;
+    result[3] = 0;
+    result[12] = 1;
   };
 };

@@ -190,6 +224,7 @@
   cpy3(result, f);
   cpy3x3(result + 3, A);
   cpy3x3(result + 12, B);
+
 }

@@ -224,6 +259,7 @@
         rho,
         result, A, B);

+
     reaction += 3;
     velocity += 3;
     mu++;
@@ -260,123 +296,99 @@
   SET3(velocity);
   SET3(rho);

-
-
   *A01 = 0.;
   *A02 = 0.;
-  *A10 = 0.;
-  *A20 = 0.;
-
   *B01 = 0.;
   *B02 = 0.;

-  double p0, p1, p2;
-
-  p0 = *reaction0 - *rho0 * *velocity0;
-  p1 = *reaction1 - *rho1 * *velocity1;
-  p2 = *reaction2 - *rho2 * *velocity2;
-
-  // note : rmu was reaction[i0]*mu[i]
-  double rmu = mu * fmax(0, p0);
-
-  double p = hypot(p1, p2);
-
-  if (p0 >= 0)
-  {
-    *ACF0 -= *reaction0; // note : this is -PHI p425
-
-    if (A && B)
-    {
-      // DUnPHI2
-      *A00 = *rho0;
-      *B00 = 0.;
-    }
-
-
-  }
-
-  else
-  {
-    *ACF0 = -*reaction0;
-
-    if (A && B)
-    {
-      // DUnPHI2
-      *A00 = 0.;
-      *B00 = 1.;
-    }
-  }
-
-
-  if (p > rmu)
-  {
-
-    // outside disk
-    if (A && B)
-    {
-
-      double rho1rmu, rho2rmu;
-      rho1rmu = *rho1 * rmu;
-      rho2rmu = *rho2 * rmu;
-
-      frictionContact3D_gamma(ACF0, A00, &p);
-
-      int positivepnv = *ACF0 > 0;
-
-      // DRnPHI3
-      *B10 = - mu * positivepnv * p1 / p; // not rmu
-      *B20 = - mu * positivepnv * p2 / p; // not rmu
-
-      // DRtPHI3
-      *B11 = 1. - rmu* *A11;
-      *B12 = - rmu* *A12;
-      *B21 = *B12;
-      *B22 = 1. - rmu* *A22;
-
-      // DUtPHI3
-      *A11 *= rho1rmu;
-      *A12 *= rho1rmu;
-      *A21 *= rho2rmu;
-      *A22 *= rho2rmu;
-
-    }
-
-    assert(p > 0.);
-
-    *ACF1 *= rmu / p;
-    *ACF2 *= rmu / p;
-
-  }
-
-  else
-  {
-    // inside disk
-    if (A && B)
-    {
-
-      // DUtPHI3
-      *A11 = *rho1;
-      *A12 = 0.;
-      *A21 = 0.;
-      *A22 = *rho2;
-
-      // DRnPHI3
-      *B10 = 0.;
-      *B20 = 0.;
-
-      // DRtPHI3
-      *B11 = 0.;
-      *B12 = 0.;
-      *B21 = 0.;
-      *B22 = 0.;
-
-    }
-
-  }
-
-  *ACF1 -= *reaction1;
-  *ACF2 -= *reaction2;
+  double D0, D1, D2, muD0;
+
+  D0 = *reaction0 - *rho0 * *velocity0;
+  D1 = *reaction1 - *rho1 * *velocity1;
+  D2 = *reaction2 - *rho2 * *velocity2;
+
+  muD0 = mu * D0;
+
+  double hypotD1D2 = hypot(D1, D2);
+
+
+  if (muD0 <= 0.)
+  {
+
+
+    *ACF1 = *reaction1;
+    *ACF2 = *reaction2;
+    *A10 = 0.;
+    *A11 = 0.;
+    *A12 = 0.;
+    *A20 = 0.;
+    *A21 = 0.;
+    *A22 = 0.;
+    *B10 = 0.;
+    *B11 = 1.;
+    *B12 = 0.;
+    *B20 = 0.;
+    *B22 = 1.;
+
+  };
+
+  if (hypotD1D2 <= muD0)
+  {
+    *ACF1 = *reaction1 - D1;
+    *ACF2 = *reaction2 - D2;
+    *A10 = 0.;
+    *A11 = *rho1;
+    *A12 = 0.;
+    *A20 = 0.;
+    *A21 = 0.;
+    *A22 = *rho2;
+
+    *B10 = 0.;
+    *B11 = 0.;
+    *B12 = 0.;
+  }
+
+  if (D0 < 0.)
+  {
+    *ACF0 = *reaction0;
+    *A00 = 0.;
+    *B00 = 1.;
+  }
+
+  if (D0 >= 0.)
+  {
+    *ACF0 = *reaction0 - D0;
+    *A00 = *rho0;
+    *B00 = 0.;
+  }
+
+  if (muD0 < hypotD1D2)
+  {
+    double cubehypotD1D2 = hypotD1D2 * hypotD1D2 * hypotD1D2;
+    double muD0rho1 = muD0* *rho1;
+
+    *ACF1 = *reaction1 - muD0 * D1 / hypotD1D2;
+    *ACF2 = *reaction2 - muD0 * D2 / hypotD1D2;
+
+    *A10 = mu * D1* *rho0 / hypotD1D2;
+    *A11 = -muD0rho1 * D1 * D1 / cubehypotD1D2 + muD0rho1 / hypotD1D2;
+    *A12 = - D0 * D1 * D2 * mu**rho2 / cubehypotD1D2;
+
+    *A20 = D2 * mu* *rho0 / hypotD1D2;
+    *A21 = - D0 * D1 * D2 * mu* *rho1 / cubehypotD1D2;
+    *A22 = - muD0* *rho2 * D2 * D2 / cubehypotD1D2 + muD0* *rho2 / hypotD1D2;
+
+    *B10 = - mu * D1 / hypotD1D2;
+    *B11 = 1 + muD0 * D1 * D1 / cubehypotD1D2 - muD0 / hypotD1D2;
+    *B12 =  muD0 * D1 * D2 / cubehypotD1D2;
+
+    *B20 = - mu * D2 / hypotD1D2;
+    *B21 =  muD0 * D1 * D2 / cubehypotD1D2;
+    *B22 = 1 + muD0 * D2 * D2 / cubehypotD1D2 - muD0 / hypotD1D2;
+
+  }
+
 };


AMDGPU: Add readonly to InstrMapping functions

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@248474 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Target/AMDGPU/SIInstrInfo.h
+++ lib/Target/AMDGPU/SIInstrInfo.h
@@ -113,6 +113,8 @@
   // register.  If there is no hardware instruction that can store to \p
   // DstRC, then AMDGPU::COPY is returned.
   unsigned getMovOpcode(const TargetRegisterClass *DstRC) const;
+
+  LLVM_READONLY
   int commuteOpcode(const MachineInstr &MI) const;

   MachineInstr *commuteInstruction(MachineInstr *MI,
@@ -348,13 +350,25 @@
 };

 namespace AMDGPU {
-
+  LLVM_READONLY
   int getVOPe64(uint16_t Opcode);
+
+  LLVM_READONLY
   int getVOPe32(uint16_t Opcode);
+
+  LLVM_READONLY
   int getCommuteRev(uint16_t Opcode);
+
+  LLVM_READONLY
   int getCommuteOrig(uint16_t Opcode);
+
+  LLVM_READONLY
   int getAddr64Inst(uint16_t Opcode);
+
+  LLVM_READONLY
   int getAtomicRetOp(uint16_t Opcode);
+
+  LLVM_READONLY
   int getAtomicNoRetOp(uint16_t Opcode);

   const uint64_t RSRC_DATA_FORMAT = 0xf00000000000LL;


Eina: Windows fixes

Eina: Windows fixes

add eina_file_path_sanitize() which was missing in the windows port
add locks
synchronize a bit with the linux version

SVN revision: 67422

--- src/lib/eina_file_win32.c
+++ src/lib/eina_file_win32.c
@@ -41,7 +41,7 @@
 #include <windows.h>
 #undef WIN32_LEAN_AND_MEAN

-//#include <Evil.h>
+#include <Evil.h>

 #include "eina_config.h"
 #include "eina_private.h"
@@ -52,6 +52,8 @@
 #include "eina_stringshare.h"
 #include "eina_hash.h"
 #include "eina_list.h"
+#include "eina_lock.h"
+#include "eina_log.h"

 /*============================================================================*
  *                                  Local                                     *
@@ -123,6 +125,8 @@
    Eina_Hash *rmap;
    void *global_map;

+   Eina_Lock lock;
+
    ULONGLONG length;
    ULONGLONG mtime;

@@ -147,8 +151,7 @@
 };

 static Eina_Hash *_eina_file_cache = NULL;
-static Eina_List *_eina_file_cache_lru = NULL;
-static Eina_List *_eina_file_cache_delete = NULL;
+static Eina_Lock _eina_file_lock_cache;

 static int _eina_file_log_dom = -1;

@@ -486,6 +489,86 @@
      ^ eina_hash_int64(&key[1], sizeof (unsigned long int));
 }

+static char *
+_eina_file_win32_escape(const char *path, size_t *length)
+{
+   char *result = strdup(path ? path : "");
+   char *p = result;
+   char *q = result;
+   size_t len;
+
+   if (!result)
+     return NULL;
+
+   if (length) len = *length;
+   else len = strlen(result);
+
+   while ((p = strchr(p, '/')))
+     {
+        // remove double `/'
+        if (p[1] == '/')
+          {
+             memmove(p, p + 1, --len - (p - result));
+             result[len] = '\0';
+          }
+        else
+          if (p[1] == '.'
+              && p[2] == '.')
+            {
+               // remove `/../'
+               if (p[3] == '/')
+                 {
+                    char tmp;
+
+                    len -= p + 3 - q;
+                    memmove(q, p + 3, len - (q - result));
+                    result[len] = '\0';
+                    p = q;
+
+                    /* Update q correctly. */
+                    tmp = *p;
+                    *p = '\0';
+                    q = strrchr(result, '/');
+                    if (!q) q = result;
+                    *p = tmp;
+                 }
+               else
+                 // remove '/..$'
+                 if (p[3] == '\0')
+                   {
+                      len -= p + 2 - q;
+                      result[len] = '\0';
+                      q = p;
+                      ++p;
+                   }
+                 else
+                   {
+                      q = p;
+                      ++p;
+                   }
+            }
+          else
+            {
+               q = p;
+               ++p;
+            }
+     }
+
+   if (length)
+     *length = len;
+
+   return result;
+}
+
+
+/**
+ * @endcond
+ */
+
+/*============================================================================*
+ *                                 Global                                     *
+ *============================================================================*/
+
 Eina_Bool
 eina_file_init(void)
 {
@@ -497,7 +580,7 @@
         return EINA_FALSE;
      }

-   _eina_file_cache = eina_hash_string_djb2_new(EINA_FREE_CB(_eina_file_real_close));
+   _eina_file_cache = eina_hash_string_djb2_new(NULL);
    if (!_eina_file_cache)
      {
         ERR("Could not create cache.");
@@ -506,21 +589,14 @@
         return EINA_FALSE;
      }

+   eina_lock_new(&_eina_file_lock_cache);
+
    return EINA_TRUE;
 }

 Eina_Bool
 eina_file_shutdown(void)
 {
-   Eina_File *f;
-   Eina_List *l;
-
-   EINA_LIST_FREE(_eina_file_cache_delete, f)
-     _eina_file_real_close(f);
-
-   EINA_LIST_FOREACH(_eina_file_cache_lru, l, f)
-     eina_hash_del(_eina_file_cache, f->filename, f);
-
    if (eina_hash_population(_eina_file_cache) > 0)
      {
         Eina_Iterator *it;
@@ -534,23 +610,56 @@

    eina_hash_free(_eina_file_cache);

+   eina_lock_free(&_eina_file_lock_cache);
+
    eina_log_domain_unregister(_eina_file_log_dom);
    _eina_file_log_dom = -1;
    return EINA_TRUE;
 }

-
-/**
- * @endcond
- */
-
-/*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
-
 /*============================================================================*
  *                                   API                                      *
  *============================================================================*/
+
+
+EAPI char *
+eina_file_path_sanitize(const char *path)
+{
+   char *result = NULL;
+   size_t len;
+
+   if (!path) return NULL;
+
+   len = strlen(path);
+   if (len < 3) return NULL;
+
+   if (!evil_path_is_absolute(path))
+     {
+        DWORD l;
+
+        l = GetCurrentDirectory(0, NULL);
+        if (l > 0)
+          {
+             char *cwd;
+             DWORD l2;
+
+             cwd = alloca(sizeof(char) * (l + 1));
+             l2 = GetCurrentDirectory(l + 1, cwd);
+             if (l2 == l)
+               {
+                  char *tmp;
+
+                  len += l + 2;
+                  tmp = alloca(sizeof (char) * len);
+                  snprintf(tmp, len, "%s/%s", cwd, path);
+                  tmp[len - 1] = '\0';
+                  result = tmp;
+               }
+          }
+     }
+
+   return _eina_file_win32_escape(result ? result : path, &len);
+}

 EAPI Eina_Bool
 eina_file_dir_list(const char *dir,
@@ -657,6 +766,8 @@
    char               *new_dir;
    size_t              length;

+   EINA_SAFETY_ON_NULL_RETURN_VAL(dir, NULL);
+
    if (!dir || !*dir)
       return NULL;

@@ -707,6 +818,8 @@
    char                      *new_dir;
    size_t                     length;

+   EINA_SAFETY_ON_NULL_RETURN_VAL(dir, NULL);
+
    if (!dir || !*dir)
       return NULL;

@@ -764,10 +877,11 @@
 }

 EAPI Eina_File *
-eina_file_open(const char *filename, Eina_Bool shared)
+eina_file_open(const char *path, Eina_Bool shared)
 {
    Eina_File *file;
    Eina_File *n;
+   char *filename;
    HANDLE handle;
    HANDLE fm;
    WIN32_FILE_ATTRIBUTE_DATA fad;
@@ -775,8 +889,10 @@
    ULARGE_INTEGER mtime;
    Eina_Bool create = EINA_FALSE;

-   /* FIXME: always open absolute path (need to fix filename according to current
-      directory) */
+   EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
+
+   filename = eina_file_path_sanitize(path);
+   if (!filename) return NULL;

    /* FIXME: how to emulate shm_open ? Just OpenFileMapping ? */
 #if 0
@@ -805,33 +921,29 @@
    mtime.u.LowPart = fad.ftLastWriteTime.dwLowDateTime;
    mtime.u.HighPart = fad.ftLastWriteTime.dwHighDateTime;

+   eina_lock_take(&_eina_file_lock_cache);
+
    file = eina_hash_find(_eina_file_cache, filename);
    if (file &&
-       (file->mtime != mtime.QuadPart || file->length != length.QuadPart))
-     {
-        create = EINA_TRUE;
-
-        if (file->refcount == 0)
+       (file->mtime == mtime.QuadPart && file->length == length.QuadPart))
+     {
+        file->delete_me = EINA_TRUE;
+        eina_hash_del(_eina_file_cache, file->filename, file);
+        _eina_file_real_close(file);
+        file = NULL;
+     }
+
+   if (!file)
+     {
+        n = malloc(sizeof (Eina_File) + strlen(filename) + 1);
+        if (!n)
           {
-             _eina_file_cache_lru = eina_list_prepend(_eina_file_cache_lru, file);
-             eina_hash_del(_eina_file_cache, file->filename, file);
-
-             file = NULL;
+             eina_lock_release(&_eina_file_lock_cache);
+             goto close_fm;
           }
-        else if (!file->delete_me)
-          {
-             file->delete_me = EINA_TRUE;
-             _eina_file_cache_delete = eina_list_prepend(_eina_file_cache_delete, file);
-          }
-     }
-
-   if (!file || create)
-     {
-        n = calloc(1, sizeof (Eina_File));
-        if (!n)
-          goto close_fm;
-
-        n->filename = eina_stringshare_add(filename);
+
+        n->filename = (char*) (n + 1);
+        strcpy((char*) n->filename, filename);
         n->map = eina_hash_new(EINA_KEY_LENGTH(_eina_file_map_key_length),
                                EINA_KEY_CMP(_eina_file_map_key_cmp),
                                EINA_KEY_HASH(_eina_file_map_key_hash),
@@ -839,6 +951,7 @@
                                3);
         n->rmap = eina_hash_pointer_new(NULL);
         n->global_map = MAP_FAILED;
+        n->global_refcount = 0;
         n->length = length.QuadPart;
         n->mtime = mtime.QuadPart;
         n->refcount = 0;
@@ -846,8 +959,8 @@
         n->fm = fm;
         n->shared = shared;
         n->delete_me = EINA_FALSE;
-
-        eina_hash_set(_eina_file_cache, filename, n);
+        eina_lock_new(&n->lock);
+        eina_hash_direct_add(_eina_file_cache, n->filename, n);
      }
    else
      {
@@ -855,12 +968,14 @@
         CloseHandle(handle);

         n = file;
-
-        if (n->refcount == 0)
-          _eina_file_cache_lru = eina_list_remove(_eina_file_cache_lru, n);
-     }
-
+     }
+   eina_lock_take(&n->lock);
    n->refcount++;
+   eina_lock_release(&n->lock);
+
+   eina_lock_release(&_eina_file_lock_cache);
+
+   free(filename);

    return n;

@@ -875,42 +990,48 @@
 EAPI void
 eina_file_close(Eina_File *file)
 {
+   EINA_SAFETY_ON_NULL_RETURN(file);
+
+   eina_lock_take(&file->lock);
    file->refcount--;
+   eina_lock_release(&file->lock);

    if (file->refcount != 0) return ;
-
-   if (file->delete_me)
-     {
-        _eina_file_cache_delete = eina_list_remove(_eina_file_cache_delete, file);
-        _eina_file_real_close(file);
-     }
-   else
-     {
-        _eina_file_cache_lru = eina_list_prepend(_eina_file_cache_lru, file);
-     }
+   eina_lock_take(&_eina_file_lock_cache);
+
+   eina_hash_del(_eina_file_cache, file->filename, file);
+   _eina_file_real_close(file);
+
+   eina_lock_release(&_eina_file_lock_cache);
 }

 EAPI size_t
 eina_file_size_get(Eina_File *file)
 {
+   EINA_SAFETY_ON_NULL_RETURN_VAL(file, 0);
    return file->length;
 }

 EAPI time_t
 eina_file_mtime_get(Eina_File *file)
 {
+   EINA_SAFETY_ON_NULL_RETURN_VAL(file, 0);
   return file->mtime;
 }

 EAPI const char *
 eina_file_filename_get(Eina_File *file)
 {
+   EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
    return file->filename;
 }

 EAPI void *
 eina_file_map_all(Eina_File *file, Eina_File_Populate rule __UNUSED__)
 {
+   EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
+
+   eina_lock_take(&file->lock);
    if (file->global_map == MAP_FAILED)
      {
         void  *data;
@@ -929,6 +1050,7 @@
         return file->global_map;
      }

+   eina_lock_release(&file->lock);
    return NULL;
 }

@@ -938,6 +1060,8 @@
 {
    Eina_File_Map *map;
    unsigned long int key[2];
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);

    if (offset > file->length)
      return NULL;
@@ -949,6 +1073,8 @@

    key[0] = offset;
    key[1] = length;
+
+   eina_lock_take(&file->lock);

    map = eina_hash_find(file->map, &key);
    if (!map)
@@ -983,21 +1109,25 @@

    map->refcount++;

+   eina_lock_release(&file->lock);
+
    return map->map;
 }

 EAPI void
 eina_file_map_free(Eina_File *file, void *map)
 {
+   EINA_SAFETY_ON_NULL_RETURN(file);
+
+   eina_lock_take(&file->lock);
+
    if (file->global_map == map)
      {
         file->global_refcount--;

-        if (file->global_refcount > 0) return ;
-
-        /* FIXME: are we sure that file->global_map != MAP_FAILED ? */
-        if (file->global_map != MAP_FAILED)
-          UnmapViewOfFile(file->global_map);
+        if (file->global_refcount > 0) goto on_exit;
+
+        UnmapViewOfFile(file->global_map);
         file->global_map = MAP_FAILED;
      }
    else
@@ -1010,7 +1140,7 @@

         em->refcount--;

-        if (em->refcount > 0) return ;
+        if (em->refcount > 0) goto on_exit;

         key[0] = em->offset;
         key[1] = em->length;
@@ -1018,4 +1148,7 @@
         eina_hash_del(file->rmap, &map, em);
         eina_hash_del(file->map, &key, em);
      }
-}
+
+ on_exit:
+   eina_lock_release(&file->lock);
+}


The max step is no longer dependent on the channel count

--- Alc/ALu.c
+++ Alc/ALu.c
@@ -207,7 +207,7 @@
         ALbuffer *ALBuffer;
         if((ALBuffer=BufferListItem->buffer) != NULL)
         {
-            ALsizei maxstep = BUFFERSIZE / ALSource->NumChannels;
+            ALsizei maxstep = BUFFERSIZE;
             maxstep -= ResamplerPadding[Resampler] +
                        ResamplerPrePadding[Resampler] + 1;
             maxstep = mini(maxstep, INT_MAX>>FRACTIONBITS);
@@ -701,7 +701,7 @@
         {
             /* Calculate fixed-point stepping value, based on the pitch, buffer
              * frequency, and output frequency. */
-            ALsizei maxstep = BUFFERSIZE / ALSource->NumChannels;
+            ALsizei maxstep = BUFFERSIZE;
             maxstep -= ResamplerPadding[Resampler] +
                        ResamplerPrePadding[Resampler] + 1;
             maxstep = mini(maxstep, INT_MAX>>FRACTIONBITS);


Updated unit tests to fixed padding

Updated unit tests to fixed padding


color_class: Check return value of elm_layout_theme_set

--- src/lib/elm_color_class.c
+++ src/lib/elm_color_class.c
@@ -715,7 +715,8 @@
      }
    cc->winid = winid;
    cc->ly = ly = elm_layout_add(obj);
-   elm_layout_theme_set(ly, "layout", "colorclass", "base");
+   if (!elm_layout_theme_set(ly, "layout", "colorclass", "base"))
+     CRI("Failed to set layout!");
    elm_layout_signal_callback_add(ly, "elm,colorclass,select,*", "elm", _colorclass_select, cc);
    elm_layout_signal_callback_add(ly, "elm,colorclass,deactivate", "elm", _colorclass_deactivate, cc);
    elm_layout_signal_callback_add(ly, "elm,colorclass,dismiss", "elm", _colorclass_dismiss, cc);