mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 07:23:03 +01:00
The merge continued.
This commit is contained in:
parent
1bf9a4ae70
commit
8ef0e6aba7
@ -366,4 +366,3 @@ bool ClumpletWriter::deleteWithTag(UCHAR tag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -57,8 +57,6 @@ static const char* DEFAULT_PATH =
|
|||||||
"/tmp/";
|
"/tmp/";
|
||||||
#elif defined(WIN_NT)
|
#elif defined(WIN_NT)
|
||||||
"c:\\temp\\";
|
"c:\\temp\\";
|
||||||
#elif defined(VMS)
|
|
||||||
"SYS$SCRATCH:";
|
|
||||||
#else
|
#else
|
||||||
NULL;
|
NULL;
|
||||||
#endif
|
#endif
|
||||||
|
@ -357,6 +357,15 @@ extern "C" {
|
|||||||
va_end(params);
|
va_end(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Need macros here - va_copy()/va_end() should be called in SAME function
|
||||||
|
#ifdef HAVE_VA_COPY
|
||||||
|
#define FB_VA_COPY(to, from) va_copy(to, from)
|
||||||
|
#define FB_CLOSE_VACOPY(to) va_end(to)
|
||||||
|
#else
|
||||||
|
#define FB_VA_COPY(to, from) memcpy(to, from, sizeof (va_list))
|
||||||
|
#define FB_CLOSE_VACOPY(to)
|
||||||
|
#endif
|
||||||
|
|
||||||
void AbstractString::vprintf(const char* format, va_list params) {
|
void AbstractString::vprintf(const char* format, va_list params) {
|
||||||
#ifndef HAVE_VSNPRINTF
|
#ifndef HAVE_VSNPRINTF
|
||||||
#error NS: I am lazy to implement version of this routine based on plain vsprintf.
|
#error NS: I am lazy to implement version of this routine based on plain vsprintf.
|
||||||
@ -364,16 +373,21 @@ extern "C" {
|
|||||||
#error For example, consider importing library from http://www.ijs.si/software/snprintf/
|
#error For example, consider importing library from http://www.ijs.si/software/snprintf/
|
||||||
#error to Firebird extern repository
|
#error to Firebird extern repository
|
||||||
#endif
|
#endif
|
||||||
enum {tempsize = 4096};
|
enum {tempsize = 256};
|
||||||
char temp[tempsize];
|
char temp[tempsize];
|
||||||
int l = VSNPRINTF(temp, tempsize, format, params);
|
va_list paramsCopy;
|
||||||
|
FB_VA_COPY(paramsCopy, params);
|
||||||
|
int l = VSNPRINTF(temp, tempsize, format, paramsCopy);
|
||||||
|
FB_CLOSE_VACOPY(paramsCopy);
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
size_type n = sizeof(temp);
|
size_type n = sizeof(temp);
|
||||||
while (true) {
|
while (true) {
|
||||||
n *= 2;
|
n *= 2;
|
||||||
if (n > max_length())
|
if (n > max_length())
|
||||||
n = max_length();
|
n = max_length();
|
||||||
l = VSNPRINTF(baseAssign(n), n + 1, format, params);
|
FB_VA_COPY(paramsCopy, params);
|
||||||
|
l = VSNPRINTF(baseAssign(n), n + 1, format, paramsCopy);
|
||||||
|
FB_CLOSE_VACOPY(paramsCopy);
|
||||||
if (l >= 0)
|
if (l >= 0)
|
||||||
break;
|
break;
|
||||||
if (n >= max_length()) {
|
if (n >= max_length()) {
|
||||||
@ -390,7 +404,9 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
resize(l);
|
resize(l);
|
||||||
VSNPRINTF(begin(), l + 1, format, params);
|
FB_VA_COPY(paramsCopy, params);
|
||||||
|
VSNPRINTF(begin(), l + 1, format, paramsCopy);
|
||||||
|
FB_CLOSE_VACOPY(paramsCopy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,12 +36,7 @@
|
|||||||
//
|
//
|
||||||
// TLS variable type should be smaller than size of pointer to stay portable
|
// TLS variable type should be smaller than size of pointer to stay portable
|
||||||
|
|
||||||
#if !defined(MULTI_THREAD)
|
#if defined(HAVE___THREAD)
|
||||||
// Single-threaded case
|
|
||||||
# define TLS_DECLARE(TYPE, NAME) TYPE NAME
|
|
||||||
# define TLS_GET(NAME) NAME
|
|
||||||
# define TLS_SET(NAME, VALUE) NAME = (VALUE)
|
|
||||||
#elif defined(HAVE___THREAD)
|
|
||||||
// Recent GCC supports __thread keyword. Sun compiler and HP-UX should have it too
|
// Recent GCC supports __thread keyword. Sun compiler and HP-UX should have it too
|
||||||
# define TLS_DECLARE(TYPE, NAME) __thread TYPE NAME
|
# define TLS_DECLARE(TYPE, NAME) __thread TYPE NAME
|
||||||
# define TLS_GET(NAME) NAME
|
# define TLS_GET(NAME) NAME
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
#include "firebird.h"
|
#include "firebird.h"
|
||||||
|
|
||||||
#ifdef MULTI_THREAD
|
|
||||||
#ifdef WIN_NT
|
#ifdef WIN_NT
|
||||||
// It is relatively easy to avoid using this header. Maybe do the same stuff like
|
// It is relatively easy to avoid using this header. Maybe do the same stuff like
|
||||||
// in thd.h ? This is Windows platform maintainers choice
|
// in thd.h ? This is Windows platform maintainers choice
|
||||||
@ -44,11 +43,9 @@
|
|||||||
#include <synch.h>
|
#include <synch.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif /* MULTI_THREAD */
|
|
||||||
|
|
||||||
namespace Firebird {
|
namespace Firebird {
|
||||||
|
|
||||||
#ifdef MULTI_THREAD
|
|
||||||
#ifdef WIN_NT
|
#ifdef WIN_NT
|
||||||
|
|
||||||
// Generic process-local mutex and spinlock. The latter
|
// Generic process-local mutex and spinlock. The latter
|
||||||
@ -167,25 +164,6 @@ public:
|
|||||||
|
|
||||||
#endif //WIN_NT
|
#endif //WIN_NT
|
||||||
|
|
||||||
#else //MULTI_THREAD
|
|
||||||
|
|
||||||
// Non-MT version
|
|
||||||
class Mutex {
|
|
||||||
public:
|
|
||||||
Mutex() {
|
|
||||||
}
|
|
||||||
~Mutex() {
|
|
||||||
}
|
|
||||||
void enter() {
|
|
||||||
}
|
|
||||||
void leave() {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef Mutex Spinlock;
|
|
||||||
|
|
||||||
#endif //MULTI_THREAD
|
|
||||||
|
|
||||||
// RAII holder of mutex lock
|
// RAII holder of mutex lock
|
||||||
class MutexLockGuard {
|
class MutexLockGuard {
|
||||||
public:
|
public:
|
||||||
|
@ -281,7 +281,7 @@ namespace Firebird
|
|||||||
static const T& generate(const void* sender, const T* Item) { return Item; }
|
static const T& generate(const void* sender, const T* Item) { return Item; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Template for default value comparsion
|
// Template for default value comparator
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class ObjectComparator {
|
class ObjectComparator {
|
||||||
public:
|
public:
|
||||||
@ -304,6 +304,7 @@ namespace Firebird
|
|||||||
typedef ObjectsArray <ObjectValue, SortedArray<ObjectValue*,
|
typedef ObjectsArray <ObjectValue, SortedArray<ObjectValue*,
|
||||||
ObjectStorage, const ObjectKey*, ObjectKeyOfValue,
|
ObjectStorage, const ObjectKey*, ObjectKeyOfValue,
|
||||||
ObjectCmp> > inherited;
|
ObjectCmp> > inherited;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SortedObjectsArray(MemoryPool& p) :
|
explicit SortedObjectsArray(MemoryPool& p) :
|
||||||
ObjectsArray <ObjectValue, SortedArray<ObjectValue*,
|
ObjectsArray <ObjectValue, SortedArray<ObjectValue*,
|
||||||
@ -315,6 +316,12 @@ namespace Firebird
|
|||||||
ObjectStorage, const ObjectKey*, ObjectKeyOfValue,
|
ObjectStorage, const ObjectKey*, ObjectKeyOfValue,
|
||||||
ObjectCmp>*>(this)->find(pItem, pos);
|
ObjectCmp>*>(this)->find(pItem, pos);
|
||||||
}
|
}
|
||||||
|
size_t add(const ObjectValue& item) {
|
||||||
|
return inherited::add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ObjectValue& add(); // Unusable when sorted
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Firebird
|
} // namespace Firebird
|
||||||
|
@ -164,8 +164,6 @@ public:
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#ifdef MULTI_THREAD
|
|
||||||
|
|
||||||
#ifdef SOLARIS_MT
|
#ifdef SOLARIS_MT
|
||||||
|
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
@ -319,32 +317,6 @@ public:
|
|||||||
|
|
||||||
#endif /*solaris threading (not posix)*/
|
#endif /*solaris threading (not posix)*/
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
namespace Firebird {
|
|
||||||
|
|
||||||
// Non-threaded version
|
|
||||||
class RWLock
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
// Forbid copy constructor
|
|
||||||
RWLock(const RWLock& source);
|
|
||||||
public:
|
|
||||||
RWLock() {
|
|
||||||
}
|
|
||||||
~RWLock() { }
|
|
||||||
void beginRead() { }
|
|
||||||
bool tryBeginRead() { return true; }
|
|
||||||
void endRead() { }
|
|
||||||
bool tryBeginWrite() { return true; }
|
|
||||||
void beginWrite() { }
|
|
||||||
void endWrite() { }
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Firebird
|
|
||||||
|
|
||||||
#endif /*MULTI_THREAD*/
|
|
||||||
|
|
||||||
#endif /*!WIN_NT*/
|
#endif /*!WIN_NT*/
|
||||||
|
|
||||||
namespace Firebird {
|
namespace Firebird {
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#define CLASSES_SEMAPHORE_H
|
#define CLASSES_SEMAPHORE_H
|
||||||
|
|
||||||
#include "../jrd/gdsassert.h"
|
#include "../jrd/gdsassert.h"
|
||||||
|
|
||||||
#ifdef WIN_NT
|
#ifdef WIN_NT
|
||||||
// Note: Windows does not need signal safe version of the class
|
// Note: Windows does not need signal safe version of the class
|
||||||
|
|
||||||
@ -74,9 +75,7 @@ public:
|
|||||||
|
|
||||||
} // namespace Firebird
|
} // namespace Firebird
|
||||||
|
|
||||||
#else //WIN_NT
|
#else // WIN_NT
|
||||||
|
|
||||||
#ifdef MULTI_THREAD
|
|
||||||
|
|
||||||
#ifdef HAVE_SEMAPHORE_H
|
#ifdef HAVE_SEMAPHORE_H
|
||||||
|
|
||||||
@ -225,18 +224,18 @@ public:
|
|||||||
system_call_failed::raise("sem_timedwait", errcode);
|
system_call_failed::raise("sem_timedwait", errcode);
|
||||||
return false; // avoid warnings
|
return false; // avoid warnings
|
||||||
}
|
}
|
||||||
#endif //HAVE_SEM_TIMEDWAIT
|
#endif // HAVE_SEM_TIMEDWAIT
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HAVE_SEM_TIMEDWAIT
|
#ifdef HAVE_SEM_TIMEDWAIT
|
||||||
// In case when sem_timedwait() is implemented by host OS,
|
// In case when sem_timedwait() is implemented by host OS,
|
||||||
// SignalSafeSemaphore and Semaphore are just the same
|
// SignalSafeSemaphore and Semaphore are just the same
|
||||||
typedef SignalSafeSemaphore Semaphore;
|
typedef SignalSafeSemaphore Semaphore;
|
||||||
#endif //HAVE_SEM_TIMEDWAIT
|
#endif // HAVE_SEM_TIMEDWAIT
|
||||||
|
|
||||||
} // namespace Firebird
|
} // namespace Firebird
|
||||||
|
|
||||||
#endif //HAVE_SEMAPHORE_H
|
#endif // HAVE_SEMAPHORE_H
|
||||||
|
|
||||||
#ifndef HAVE_SEM_TIMEDWAIT
|
#ifndef HAVE_SEM_TIMEDWAIT
|
||||||
// Should implement Semaphore independent from SignalSafeSemaphore.
|
// Should implement Semaphore independent from SignalSafeSemaphore.
|
||||||
@ -341,7 +340,7 @@ public:
|
|||||||
|
|
||||||
} // namespace Firebird
|
} // namespace Firebird
|
||||||
|
|
||||||
#else //defined(HAVE_SYS_SEM_H) && defined(HAVE_SEMTIMEDOP)
|
#else // defined(HAVE_SYS_SEM_H) && defined(HAVE_SEMTIMEDOP)
|
||||||
|
|
||||||
// This implementation will NOT work with FB > 2.1
|
// This implementation will NOT work with FB > 2.1
|
||||||
#ifdef SOLARIS
|
#ifdef SOLARIS
|
||||||
@ -529,29 +528,10 @@ public:
|
|||||||
|
|
||||||
} // namespace Firebird
|
} // namespace Firebird
|
||||||
|
|
||||||
#endif //defined(HAVE_SYS_SEM_H) && defined(HAVE_SEMTIMEDOP)
|
#endif // defined(HAVE_SYS_SEM_H) && defined(HAVE_SEMTIMEDOP)
|
||||||
|
|
||||||
#endif //HAVE_SEM_TIMEDWAIT
|
#endif // HAVE_SEM_TIMEDWAIT
|
||||||
|
|
||||||
#else //MULTI_THREAD
|
#endif // WIN_NT
|
||||||
|
|
||||||
namespace Firebird
|
|
||||||
{
|
|
||||||
class SignalSafeSemaphore
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SignalSafeSemaphore() { }
|
|
||||||
~SignalSafeSemaphore() { }
|
|
||||||
|
|
||||||
void enter() { }
|
|
||||||
void release(SLONG count = 1) { }
|
|
||||||
bool tryEnter(int seconds = 0) { return true; }
|
|
||||||
};
|
|
||||||
typedef SignalSafeSemaphore Semaphore;
|
|
||||||
} // namespace Firebird
|
|
||||||
|
|
||||||
#endif //MULTI_THREAD
|
|
||||||
|
|
||||||
#endif //WIN_NT
|
|
||||||
|
|
||||||
#endif // CLASSES_SEMAPHORE_H
|
#endif // CLASSES_SEMAPHORE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user