New upstream version 26.0.0+dfsg1

This commit is contained in:
Sebastian Ramacher 2020-10-01 22:15:25 +02:00
parent 8e020cdacb
commit 240080891f
837 changed files with 41275 additions and 9196 deletions

View file

@ -84,7 +84,7 @@ static inline void darray_reserve(const size_t element_size, struct darray *dst,
const size_t capacity)
{
void *ptr;
if (capacity == 0 || capacity <= dst->num)
if (capacity == 0 || capacity <= dst->capacity)
return;
ptr = bmalloc(element_size * capacity);

View file

@ -197,7 +197,7 @@ wchar_t *wstrstri(const wchar_t *str, const wchar_t *find)
return NULL;
}
static inline bool is_padding(char ch)
static inline bool is_padding(int ch)
{
return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r';
}
@ -218,7 +218,7 @@ char *strdepad(char *str)
while (is_padding(*temp))
++temp;
len = strlen(str);
len = strlen(temp);
if (temp != str)
memmove(str, temp, len + 1);
@ -244,16 +244,16 @@ wchar_t *wcsdepad(wchar_t *str)
temp = str;
/* remove preceding spaces/tabs */
while (*temp == ' ' || *temp == '\t')
while (is_padding(*temp))
++temp;
len = wcslen(str);
len = wcslen(temp);
if (temp != str)
memmove(str, temp, (len + 1) * sizeof(wchar_t));
if (len) {
temp = str + (len - 1);
while (*temp == ' ' || *temp == '\t')
while (is_padding(*temp))
*(temp--) = 0;
}

View file

@ -287,7 +287,10 @@ char *os_get_executable_path_ptr(const char *name)
}
count = pathlen;
#else
ssize_t count = readlink("/proc/self/exe", exe, PATH_MAX);
ssize_t count = readlink("/proc/self/exe", exe, PATH_MAX - 1);
if (count >= 0) {
exe[count] = '\0';
}
#endif
const char *path_out = NULL;
struct dstr path;

View file

@ -60,7 +60,12 @@
#else
#if defined(__aarch64__) || defined(__arm__)
#include <arm_neon.h>
#include "sse2neon.h"
#else
#include <xmmintrin.h>
#include <emmintrin.h>
#endif
#endif

4207
libobs/util/sse2neon.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -77,15 +77,19 @@ int os_event_wait(os_event_t *event)
{
int code = 0;
pthread_mutex_lock(&event->mutex);
if (!event->signalled)
while (!event->signalled) {
code = pthread_cond_wait(&event->cond, &event->mutex);
if (code != 0)
break;
}
if (code == 0) {
if (!event->manual)
event->signalled = false;
pthread_mutex_unlock(&event->mutex);
}
pthread_mutex_unlock(&event->mutex);
return code;
}
@ -103,7 +107,7 @@ int os_event_timedwait(os_event_t *event, unsigned long milliseconds)
{
int code = 0;
pthread_mutex_lock(&event->mutex);
if (!event->signalled) {
while (!event->signalled) {
struct timespec ts;
#if defined(__APPLE__) || defined(__MINGW32__)
struct timeval tv;
@ -115,6 +119,8 @@ int os_event_timedwait(os_event_t *event, unsigned long milliseconds)
#endif
add_ms_to_ts(&ts, milliseconds);
code = pthread_cond_timedwait(&event->cond, &event->mutex, &ts);
if (code != 0)
break;
}
if (code == 0) {

View file

@ -16,6 +16,7 @@
#include "bmem.h"
#include "threading.h"
#include "util/platform.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -192,4 +193,21 @@ void os_set_thread_name(const char *name)
#endif
}
#endif
typedef HRESULT(WINAPI * set_thread_description_t)(HANDLE thread,
PCWSTR desc);
HMODULE k32 = LoadLibraryW(L"Kernel32.dll");
set_thread_description_t std = NULL;
std = (set_thread_description_t)GetProcAddress(k32,
"SetThreadDescription");
if (std) {
wchar_t *wname;
os_utf8_to_wcs_ptr(name, 0, &wname);
std(GetCurrentThread(), wname);
bfree(wname);
}
FreeLibrary(k32);
}

View file

@ -110,7 +110,7 @@ static int utf8_forbidden(unsigned char octet)
*
* It takes the following arguments:
* in - input UTF-8 string. It can be null-terminated.
* insize - size of input string in bytes. If insize is 0,
* insize - size of input string in bytes. If insize is 0,
* function continues until a null terminator is reached.
* out - result buffer for UCS-4 string. If out is NULL,
* function returns size of result buffer.
@ -143,7 +143,7 @@ size_t utf8_to_wchar(const char *in, size_t insize, wchar_t *out,
total = 0;
p = (unsigned char *)in;
lim = (insize != 0) ? (p + insize) : (unsigned char *)-1;
wlim = out + outsize;
wlim = out == NULL ? NULL : out + outsize;
for (; p < lim; p += n) {
if (!*p)
@ -272,7 +272,7 @@ size_t wchar_to_utf8(const wchar_t *in, size_t insize, char *out,
w = (wchar_t *)in;
wlim = (insize != 0) ? (w + insize) : (wchar_t *)-1;
p = (unsigned char *)out;
lim = p + outsize;
lim = out == NULL ? NULL : p + outsize;
total = 0;
for (; w < wlim; w++) {

24
libobs/util/util_uint64.h Normal file
View file

@ -0,0 +1,24 @@
/*
* Copyright (c) 2020 Hans Petter Selasky <hps@selasky.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#pragma once
static inline uint64_t util_mul_div64(uint64_t num, uint64_t mul, uint64_t div)
{
const uint64_t rem = num % div;
return (num / div) * mul + (rem * mul) / div;
}