mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 00:03: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
|
||||
|
||||
|
@ -57,8 +57,6 @@ static const char* DEFAULT_PATH =
|
||||
"/tmp/";
|
||||
#elif defined(WIN_NT)
|
||||
"c:\\temp\\";
|
||||
#elif defined(VMS)
|
||||
"SYS$SCRATCH:";
|
||||
#else
|
||||
NULL;
|
||||
#endif
|
||||
|
@ -357,6 +357,15 @@ extern "C" {
|
||||
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) {
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
#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 to Firebird extern repository
|
||||
#endif
|
||||
enum {tempsize = 4096};
|
||||
enum {tempsize = 256};
|
||||
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) {
|
||||
size_type n = sizeof(temp);
|
||||
while (true) {
|
||||
n *= 2;
|
||||
if (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)
|
||||
break;
|
||||
if (n >= max_length()) {
|
||||
@ -390,7 +404,9 @@ extern "C" {
|
||||
}
|
||||
else {
|
||||
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
|
||||
|
||||
#if !defined(MULTI_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)
|
||||
#if defined(HAVE___THREAD)
|
||||
// Recent GCC supports __thread keyword. Sun compiler and HP-UX should have it too
|
||||
# define TLS_DECLARE(TYPE, NAME) __thread TYPE NAME
|
||||
# define TLS_GET(NAME) NAME
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
#include "firebird.h"
|
||||
|
||||
#ifdef MULTI_THREAD
|
||||
#ifdef WIN_NT
|
||||
// It is relatively easy to avoid using this header. Maybe do the same stuff like
|
||||
// in thd.h ? This is Windows platform maintainers choice
|
||||
@ -44,11 +43,9 @@
|
||||
#include <synch.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif /* MULTI_THREAD */
|
||||
|
||||
namespace Firebird {
|
||||
|
||||
#ifdef MULTI_THREAD
|
||||
#ifdef WIN_NT
|
||||
|
||||
// Generic process-local mutex and spinlock. The latter
|
||||
@ -167,25 +164,6 @@ public:
|
||||
|
||||
#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
|
||||
class MutexLockGuard {
|
||||
public:
|
||||
|
@ -281,7 +281,7 @@ namespace Firebird
|
||||
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>
|
||||
class ObjectComparator {
|
||||
public:
|
||||
@ -304,6 +304,7 @@ namespace Firebird
|
||||
typedef ObjectsArray <ObjectValue, SortedArray<ObjectValue*,
|
||||
ObjectStorage, const ObjectKey*, ObjectKeyOfValue,
|
||||
ObjectCmp> > inherited;
|
||||
|
||||
public:
|
||||
explicit SortedObjectsArray(MemoryPool& p) :
|
||||
ObjectsArray <ObjectValue, SortedArray<ObjectValue*,
|
||||
@ -315,6 +316,12 @@ namespace Firebird
|
||||
ObjectStorage, const ObjectKey*, ObjectKeyOfValue,
|
||||
ObjectCmp>*>(this)->find(pItem, pos);
|
||||
}
|
||||
size_t add(const ObjectValue& item) {
|
||||
return inherited::add(item);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectValue& add(); // Unusable when sorted
|
||||
};
|
||||
|
||||
} // namespace Firebird
|
||||
|
@ -164,8 +164,6 @@ public:
|
||||
|
||||
#else
|
||||
|
||||
#ifdef MULTI_THREAD
|
||||
|
||||
#ifdef SOLARIS_MT
|
||||
|
||||
#include <thread.h>
|
||||
@ -319,32 +317,6 @@ public:
|
||||
|
||||
#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*/
|
||||
|
||||
namespace Firebird {
|
||||
|
@ -30,6 +30,7 @@
|
||||
#define CLASSES_SEMAPHORE_H
|
||||
|
||||
#include "../jrd/gdsassert.h"
|
||||
|
||||
#ifdef WIN_NT
|
||||
// Note: Windows does not need signal safe version of the class
|
||||
|
||||
@ -74,9 +75,7 @@ public:
|
||||
|
||||
} // namespace Firebird
|
||||
|
||||
#else //WIN_NT
|
||||
|
||||
#ifdef MULTI_THREAD
|
||||
#else // WIN_NT
|
||||
|
||||
#ifdef HAVE_SEMAPHORE_H
|
||||
|
||||
@ -225,18 +224,18 @@ public:
|
||||
system_call_failed::raise("sem_timedwait", errcode);
|
||||
return false; // avoid warnings
|
||||
}
|
||||
#endif //HAVE_SEM_TIMEDWAIT
|
||||
#endif // HAVE_SEM_TIMEDWAIT
|
||||
};
|
||||
|
||||
#ifdef HAVE_SEM_TIMEDWAIT
|
||||
// In case when sem_timedwait() is implemented by host OS,
|
||||
// SignalSafeSemaphore and Semaphore are just the same
|
||||
typedef SignalSafeSemaphore Semaphore;
|
||||
#endif //HAVE_SEM_TIMEDWAIT
|
||||
#endif // HAVE_SEM_TIMEDWAIT
|
||||
|
||||
} // namespace Firebird
|
||||
|
||||
#endif //HAVE_SEMAPHORE_H
|
||||
#endif // HAVE_SEMAPHORE_H
|
||||
|
||||
#ifndef HAVE_SEM_TIMEDWAIT
|
||||
// Should implement Semaphore independent from SignalSafeSemaphore.
|
||||
@ -272,14 +271,14 @@ public:
|
||||
if (semctl(semId, 0, SETVAL, arg) < 0)
|
||||
system_call_failed::raise("semaphore.h: Semaphore: semctl()");
|
||||
}
|
||||
|
||||
|
||||
~Semaphore()
|
||||
{
|
||||
semun arg;
|
||||
if (semctl(semId, 0, IPC_RMID, arg) < 0)
|
||||
system_call_failed::raise("semaphore.h: ~Semaphore: semctl()");
|
||||
}
|
||||
|
||||
|
||||
bool tryEnter(int seconds = 0) // Returns true in case of success
|
||||
{
|
||||
timespec timeout;
|
||||
@ -316,12 +315,12 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void enter()
|
||||
{
|
||||
tryEnter(-1);
|
||||
}
|
||||
|
||||
|
||||
void release(SLONG count = 1)
|
||||
{
|
||||
sembuf sb;
|
||||
@ -341,7 +340,7 @@ public:
|
||||
|
||||
} // 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
|
||||
#ifdef SOLARIS
|
||||
@ -529,29 +528,10 @@ public:
|
||||
|
||||
} // 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
|
||||
|
||||
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 // WIN_NT
|
||||
|
||||
#endif // CLASSES_SEMAPHORE_H
|
||||
|
Loading…
Reference in New Issue
Block a user