Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanocasazza committed Jul 6, 2016
1 parent 5de588f commit 10126a7
Show file tree
Hide file tree
Showing 62 changed files with 3,807 additions and 1,837 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Expand Up @@ -115,6 +115,7 @@ cleandist:
$(distdir)/tests/examples/nocat/.ht* \
$(distdir)/tests/examples/nocat/image \
$(distdir)/tests/examples/nocat/webif* \
$(distdir)/tests/examples/python/*.pyc \
$(distdir)/tests/examples/TSA/log \
$(distdir)/tests/examples/TSA/TSA \
$(distdir)/tests/examples/TSA/.rnd \
Expand Down
1 change: 1 addition & 0 deletions Makefile.in
Expand Up @@ -1049,6 +1049,7 @@ cleandist:
$(distdir)/tests/examples/nocat/.ht* \
$(distdir)/tests/examples/nocat/image \
$(distdir)/tests/examples/nocat/webif* \
$(distdir)/tests/examples/python/*.pyc \
$(distdir)/tests/examples/TSA/log \
$(distdir)/tests/examples/TSA/TSA \
$(distdir)/tests/examples/TSA/.rnd \
Expand Down
11 changes: 10 additions & 1 deletion configure
Expand Up @@ -7723,6 +7723,8 @@ $as_echo "unsupported ($kernel)" >&6; }
;;
esac

enable_stdcpp="yes"

if true; then
LINUX_TRUE=
LINUX_FALSE='#'
Expand Down Expand Up @@ -7778,6 +7780,7 @@ fi
$as_echo "ok ($target_os)" >&6; }

enable_stdcpp="no"

CPPFLAGS="$CPPFLAGS -D__USE_CRTIMP -Wno-sign-compare"

if test "$enable_static" = "yes"; then
Expand Down Expand Up @@ -19969,7 +19972,13 @@ $as_echo "#define U_STATIC_ONLY 1" >>confdefs.h
enable_stdcpp="no"
fi
if test "$ac_cv_c_compiler_gnu" = "yes" -a "x$GCC_IS_CLANG" = xno -a "$target_os" != "netbsd"; then
ULIB_LIBS="$ULIB_LIBS -lgcc"
if test "$enable_stdcpp" != "yes"; then
ULIB_LIBS="$ULIB_LIBS -lgcc"
else
gcc_lib=`gcc -print-libgcc-file-name`
gcc_dir=`dirname $gcc_lib`
ULIB_LIBS="$ULIB_LIBS $gcc_dir/libstdc++.a $gcc_lib"
fi
fi
else
if false; then
Expand Down
11 changes: 10 additions & 1 deletion configure.ac
Expand Up @@ -291,6 +291,8 @@ case "$target_os" in
;;
esac

enable_stdcpp="yes"

AM_CONDITIONAL(LINUX, true)
AM_CONDITIONAL(MINGW, false)
AM_CONDITIONAL(CYGWIN, false)
Expand All @@ -303,6 +305,7 @@ case "$target_os" in
AC_MSG_RESULT([ok ($target_os)])

enable_stdcpp="no"

CPPFLAGS="$CPPFLAGS -D__USE_CRTIMP -Wno-sign-compare"

if test "$enable_static" = "yes"; then
Expand Down Expand Up @@ -577,7 +580,13 @@ if test "$enable_static" = "yes" -a "$enable_shared" = "no"; then
enable_stdcpp="no"
fi
if test "$ac_cv_c_compiler_gnu" = "yes" -a "x$GCC_IS_CLANG" = xno -a "$target_os" != "netbsd"; then
ULIB_LIBS="$ULIB_LIBS -lgcc"
if test "$enable_stdcpp" != "yes"; then
ULIB_LIBS="$ULIB_LIBS -lgcc"
else
gcc_lib=`gcc -print-libgcc-file-name`
gcc_dir=`dirname $gcc_lib`
ULIB_LIBS="$ULIB_LIBS $gcc_dir/libstdc++.a $gcc_lib"
fi
fi
else
AM_CONDITIONAL(STATIC_ONLY, false)
Expand Down
4 changes: 2 additions & 2 deletions examples/download_accelerator/main.cpp
Expand Up @@ -30,7 +30,7 @@
# include <sys/uio.h>
#endif

#define U_APPEND_LITERAL(ptr,str) (void) memcpy(ptr, str, U_CONSTANT_SIZE(str)); ptr += U_CONSTANT_SIZE(str)
#define U_APPEND_LITERAL(ptr,str) (void) apex_memcpy(ptr, str, U_CONSTANT_SIZE(str)); ptr += U_CONSTANT_SIZE(str)

/* currently-known information about a host */

Expand Down Expand Up @@ -148,7 +148,7 @@ class ProgressBar : public UEventTime {
U_INTERNAL_ASSERT(percentage <= 100)

if (percentage < 100) sprintf(p, "%2u%% ", percentage);
else (void) memcpy(p, U_CONSTANT_TO_PARAM("100%"));
else U_MEMCPY(p, "100%", U_CONSTANT_SIZE("100%"));

p += 4;

Expand Down
17 changes: 16 additions & 1 deletion examples/userver/userver.cfg.default
Expand Up @@ -142,7 +142,6 @@ userver {
# CACHE_FILE_STORE pathfile of memory cache stored on filesystem
#
# CGI_TIMEOUT timeout for cgi execution
# MOUNT_POINT mount point application (to adjust var SCRIPT_NAME)
# VIRTUAL_HOST flag to activate practice of maintaining more than one server on one machine, as differentiated by their apparent hostname
# DIGEST_AUTHENTICATION flag authentication method (yes = digest, no = basic)
#
Expand All @@ -160,6 +159,22 @@ userver {
# ----------------------------------------------------------------------------------------------------------------------------------------------------
# LIMIT_REQUEST_BODY restricts the total size of the HTTP request body sent from the client
# REQUEST_READ_TIMEOUT set timeout for receiving requests
# ------------------------------------------------------------------------------------------------------------------------------------------------
#
# ------------------------------------------------------------------------------------------------------------------------------------------------
# PHP
# ------------------------------------------------------------------------------------------------------------------------------------------------
# MOUNT_POINT mount point application (to adjust var SCRIPT_NAME)
# ------------------------------------------------------------------------------------------------------------------------------------------------
# RUBY
# ------------------------------------------------------------------------------------------------------------------------------------------------
# RUBY_LIBDIR directory to add to the ruby libdir search path
# ------------------------------------------------------------------------------------------------------------------------------------------------
# PYTHON
# ------------------------------------------------------------------------------------------------------------------------------------------------
# PY_PROJECT_APP full python name of WSGI entry point expected in form <module>.<app>
# PY_PROJECT_ROOT python module search root; relative to workdir
# PY_VIRTUALENV_PATH
# ----------------------------------------------------------------------------------------------------------------------------------------------------

http {
Expand Down
1 change: 1 addition & 0 deletions include/Makefile.am
Expand Up @@ -9,6 +9,7 @@ TO_INC = ulib/README \
ulib/base/*.h \
ulib/base/zip/*.h \
ulib/base/ssl/*.h \
ulib/base/apex/*.h \
ulib/base/miniz/*.h \
ulib/base/xxhash/*.h \
ulib/base/coder/*.h \
Expand Down
1 change: 1 addition & 0 deletions include/Makefile.in
Expand Up @@ -421,6 +421,7 @@ TO_INC = ulib/README \
ulib/base/*.h \
ulib/base/zip/*.h \
ulib/base/ssl/*.h \
ulib/base/apex/*.h \
ulib/base/miniz/*.h \
ulib/base/xxhash/*.h \
ulib/base/coder/*.h \
Expand Down
39 changes: 39 additions & 0 deletions include/ulib/base/apex/apex_memmove.h
@@ -0,0 +1,39 @@
/* apex_memmove.h */

#ifndef __APEX_MEMMOVE_H__
#define __APEX_MEMMOVE_H__

#include <ulib/base/base.h>

#if defined(__MINGW32__) || !defined(HAVE_ARCH64)
typedef void* (*pvPFpvpvs) (void*,const void*,size_t);

extern U_EXPORT pvPFpvpvs apex_memcpy;
extern U_EXPORT pvPFpvpvs apex_memmove;
#else
/**
* apex_memmove written by Trevor Herselman in 2014
*
* FORCE `CDECL` calling convention on 32-bit builds on our function pointers, because we need it to match the original `std::memmove` definition;
* in-case the user specified a different default function calling convention! (I specified __fastcall as my default calling convention and got errors! So I needed to add this!)
*/

U_EXPORT void apex_memmove_dispatcher(void);

#if !defined(__x86_64__) && !defined(_M_X64) && (defined(__i386) || defined(_M_IX86)) && (defined(_MSC_VER) || defined(__GNUC__))
#if defined(_MSC_VER)
#define APEXCALL __cdecl /* 32-bit on Visual Studio */
#else
#define APEXCALL __attribute__((__cdecl__)) /* 32-bit on GCC / LLVM (Clang) */
#endif
#else
#define APEXCALL /* 64-bit - __fastcall is default on 64-bit! */
#endif

#include <stddef.h> /* ANSI/ISO C - for `size_t` */

extern U_EXPORT void* (APEXCALL *apex_memcpy)( void *dst, const void *src, size_t size);
extern U_EXPORT void* (APEXCALL *apex_memmove)(void *dst, const void *src, size_t size);
#endif

#endif /* __APEX_MEMMOVE_H__ */
10 changes: 7 additions & 3 deletions include/ulib/base/macro.h
Expand Up @@ -464,10 +464,14 @@ static inline void u_put_unalignedp64( void* p, uint64_t val) { s

/* Optimization if it is enough a resolution of one second */

#ifdef ENABLE_THREAD
# define U_gettimeofday { if (u_pthread_time == 0) u_now->tv_sec = time(0); }
#if defined(U_LINUX) && defined(ENABLE_THREAD)
# if defined(U_LOG_DISABLE) && !defined(USE_LIBZ)
# define U_gettimeofday
# else
# define U_gettimeofday { if (u_pthread_time == 0) u_now->tv_sec = time(0); }
# endif
#else
# define U_gettimeofday u_now->tv_sec = time(0);
# define U_gettimeofday u_now->tv_sec = time(0);
#endif

/* To print size of class */
Expand Down
12 changes: 7 additions & 5 deletions include/ulib/base/utility.h
Expand Up @@ -51,6 +51,8 @@ typedef uint32_t in_addr_t;
# include <sys/sched.h>
#endif

#include <ulib/base/apex/apex_memmove.h>

#ifndef HAVE_CPU_SET_T
typedef uint64_t cpu_set_t;
#endif
Expand Down Expand Up @@ -159,14 +161,14 @@ U_EXPORT bool u_is_overlap(const char* restrict dst, const char* restrict src, s

#ifdef DEBUG
/* NB: u_strlen() and u_memcpy() conflit with /usr/include/unicode/urename.h */
U_EXPORT size_t u__strlen(const char* restrict s, const char* function);
U_EXPORT void u__strcpy( char* restrict dest, const char* restrict src);
U_EXPORT void* u__memcpy( void* restrict dest, const void* restrict src, size_t n, const char* function);
U_EXPORT char* u__strncpy(char* restrict dest, const char* restrict src, size_t n);
U_EXPORT size_t u__strlen(const char* restrict s, const char* function);
U_EXPORT void u__strcpy( char* restrict dest, const char* restrict src);
U_EXPORT void u__memcpy( void* restrict dest, const void* restrict src, size_t n, const char* function);
U_EXPORT char* u__strncpy( char* restrict dest, const char* restrict src, size_t n);
#else
# define u__strlen(s,func) strlen((s))
# define u__strcpy(dest,src) (void) strcpy( (dest),(src))
# define u__memcpy(dest,src,n,func) (void) memcpy( (dest),(src),(n))
# define u__memcpy(dest,src,n,func) (void) apex_memcpy( (dest),(src),(n))
# define u__strncpy(dest,src,n) strncpy((dest),(src),(n))
#endif

Expand Down
2 changes: 2 additions & 0 deletions include/ulib/base/win32/system.h
Expand Up @@ -125,9 +125,11 @@ extern "C" {
inline void pthread_mutex_lock(pthread_mutex_t* mutex) { EnterCriticalSection(mutex); }
inline void pthread_mutex_unlock(pthread_mutex_t* mutex) { LeaveCriticalSection(mutex); }
#endif
/*
inline char* strdup( const char* s) { return _strdup(s); }
inline int stricmp( const char* s1, const char* s2) { return _stricmp(s1, s2); }
inline int strnicmp(const char* s1, const char* s2, size_t l) { return _strnicmp(s1, s2, l); }
*/
#ifdef __cplusplus
}
#endif
Expand Down
14 changes: 7 additions & 7 deletions include/ulib/container/vector.h
Expand Up @@ -77,7 +77,7 @@ template <> class U_EXPORT UVector<void*> {
{
U_TRACE_REGISTER_OBJECT(0, UVector<void*>, "%u", n)

# ifdef U_RING_BUFFER
# if defined(U_RING_BUFFER) && !defined(U_STATIC_ONLY)
head = tail = 0;
# endif

Expand Down Expand Up @@ -207,7 +207,7 @@ template <> class U_EXPORT UVector<void*> {
U_INTERNAL_ASSERT_MINOR(pos, _length)
U_INTERNAL_ASSERT_RANGE(1,_length,_capacity)

if (--_length) (void) U_SYSCALL(memmove, "%p,%p,%u", vec + pos, vec + pos + 1, (_length - pos) * sizeof(void*));
if (--_length) (void) U_SYSCALL(apex_memmove, "%p,%p,%u", vec + pos, vec + pos + 1, (_length - pos) * sizeof(void*));
}

void erase(uint32_t first, uint32_t _last) // erase [first,last[
Expand All @@ -223,7 +223,7 @@ template <> class U_EXPORT UVector<void*> {

uint32_t new_length = (_length - (_last - first));

if (new_length) (void) U_SYSCALL(memmove, "%p,%p,%u", vec + first, vec + _last, (_length - _last) * sizeof(void*));
if (new_length) (void) U_SYSCALL(apex_memmove, "%p,%p,%u", vec + first, vec + _last, (_length - _last) * sizeof(void*));

_length = new_length;
}
Expand Down Expand Up @@ -312,7 +312,7 @@ template <> class U_EXPORT UVector<void*> {

void move(UVector<void*>& source); // add to end and reset source

#ifdef U_RING_BUFFER
#if defined(U_RING_BUFFER) && !defined(U_STATIC_ONLY)
bool isEmptyRingBuffer()
{
U_TRACE_NO_PARAM(0, "UVector<void*>::isEmptyRingBuffer()")
Expand Down Expand Up @@ -381,7 +381,7 @@ template <> class U_EXPORT UVector<void*> {
protected:
const void** vec;
uint32_t _length, _capacity;
#ifdef U_RING_BUFFER
#if defined(U_RING_BUFFER) && !defined(U_STATIC_ONLY)
volatile uint32_t tail; // input index
volatile uint32_t head; // output index
#endif
Expand Down Expand Up @@ -589,7 +589,7 @@ template <class T> class U_EXPORT UVector<T*> : public UVector<void*> {
_length = n;
}

#ifdef U_RING_BUFFER
#if defined(U_RING_BUFFER) && !defined(U_STATIC_ONLY)
bool put(const T* elem) // queue an element at the end
{
U_TRACE(0, "UVector<T*>::put(%p)", elem)
Expand Down Expand Up @@ -1077,7 +1077,7 @@ template <> class U_EXPORT UVector<UString> : public UVector<UStringRep*> {
UVector<UStringRep*>::assign(n, str.rep);
}

#ifdef U_RING_BUFFER
#if defined(U_RING_BUFFER) && !defined(U_STATIC_ONLY)
bool put(const UString& str) // queue an element at the end
{
U_TRACE(0, "UVector<UString>::put(%V)", str.rep)
Expand Down
4 changes: 2 additions & 2 deletions include/ulib/debug/macro.h
Expand Up @@ -100,7 +100,7 @@
# define U_RETURN_OBJECT(obj) return (utr.trace_return("%O",U_OBJECT_TO_TRACE((obj))),(obj))
# define U_RETURN_POINTER(ptr,type) return ((type*)utr.trace_return_type((void*)(ptr)))

# define U_MEMCPY(a,b,n) (void) U_SYSCALL(u__memcpy, "%p,%p,%u,%S",(void*)(a),(const void*)(b),(n),__PRETTY_FUNCTION__)
# define U_MEMCPY(a,b,n) U_SYSCALL_VOID(u__memcpy, "%p,%p,%u,%S",(void*)(a),(const void*)(b),(n),__PRETTY_FUNCTION__)

// Dump argument for exec()

Expand Down Expand Up @@ -242,7 +242,7 @@ if (envp) \
# define U_SYSCALL(name,format,args...) ::name(args)
# define U_SYSCALL_VOID(name,format,args...) ::name(args)

# define U_MEMCPY(a,b,n) (void) memcpy((void*)(a),(const void*)(b),(n))
# define U_MEMCPY(a,b,n) (void) apex_memcpy((void*)(a),(const void*)(b),(n))

# define U_RETURN(r) return (r)
# define U_RETURN_STRING(r) return (r)
Expand Down
4 changes: 2 additions & 2 deletions include/ulib/examples/wi_auth_declaration.h
Expand Up @@ -5015,8 +5015,6 @@ static void GET_login_validate()
return;
}

U_ASSERT_DIFFERS(*mac, *UString::str_without_mac)

brenew = true;

U_LOGGER("*** RENEW: UID(%v) IP(%v=>%v) MAC(%v=>%v) ADDRESS(%v@%v=>%v@%v) AUTH_DOMAIN(%v) ***", uid->rep,
Expand Down Expand Up @@ -7353,6 +7351,8 @@ static void GET_resync()
if (ip_server->equal(U_CLIENT_ADDRESS_TO_PARAM) == false) USSIPlugIn::setBadRequest();
else
{
if (UServer_Base::startParallelization()) return; // parent

num_users_delete = 0;

status_nodog_and_user_resync = true;
Expand Down
15 changes: 15 additions & 0 deletions include/ulib/net/client/mongodb.h
Expand Up @@ -172,6 +172,21 @@ class U_EXPORT UMongoDBClient {
# endif
}

void updateBulk(mongoc_bulk_operation_t* bulk, bson_t* query, bson_t* _update) // This function queues an update as part of a bulk operation
{
U_TRACE(0, "UMongoDBClient::updateBulk(%p,%p,%p)", bulk, query, _update)

# ifdef USE_MONGODB
U_INTERNAL_ASSERT_POINTER(client)
U_INTERNAL_ASSERT_POINTER(collection)

U_SYSCALL_VOID(mongoc_bulk_operation_update, "%p,%p,%p,%b", bulk, query, _update, false);

U_SYSCALL_VOID(bson_destroy, "%p", query);
U_SYSCALL_VOID(bson_destroy, "%p", _update);
# endif
}

# if defined(U_STDCPP_ENABLE) && defined(DEBUG)
const char* dump(bool reset) const;
# endif
Expand Down
2 changes: 1 addition & 1 deletion include/ulib/net/server/client_image.h
Expand Up @@ -297,7 +297,7 @@ class U_EXPORT UClientImage_Base : public UEventFd {

U_INTERNAL_ASSERT(U_http_info.startHeader <= sizeof(cbuffer))

(void) u__memcpy(UClientImage_Base::cbuffer, UClientImage_Base::request->c_pointer(UClientImage_Base::uri_offset), U_http_info.startHeader, __PRETTY_FUNCTION__);
U_MEMCPY(UClientImage_Base::cbuffer, UClientImage_Base::request->c_pointer(UClientImage_Base::uri_offset), U_http_info.startHeader);

U_INTERNAL_DUMP("request(%u) = %V", UClientImage_Base::request->size(), UClientImage_Base::request->rep)
U_INTERNAL_DUMP("UClientImage_Base::cbuffer(%u) = %.*S", U_http_info.startHeader, U_http_info.startHeader, UClientImage_Base::cbuffer)
Expand Down

0 comments on commit 10126a7

Please sign in to comment.