8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 21:23:03 +01:00

fixed posix build after latest changes

This commit is contained in:
alexpeshkoff 2007-04-19 09:19:11 +00:00
parent 4b5102bc94
commit 8b5dd60a66
8 changed files with 104 additions and 99 deletions

View File

@ -60,66 +60,6 @@ private:
RWLock(const RWLock& source); RWLock(const RWLock& source);
public: public:
// RAII holder of begin/end read
class ReadGuard
{
public:
explicit ReadGuard(RWLock& alock)
: lock(&alock)
{
lock->beginRead();
}
~ReadGuard()
{
release();
}
void release()
{
if (lock)
{
lock->endRead();
lock = NULL;
}
}
private:
// Forbid copy constructor
ReadGuard(const ReadGuard& source);
RWLock* lock;
};
// RAII holder of begin/end write
class WriteGuard
{
public:
explicit WriteGuard(RWLock& alock)
: lock(&alock)
{
lock->beginWrite();
}
~WriteGuard()
{
release();
}
void release()
{
if (lock)
{
lock->endWrite();
lock = NULL;
}
}
private:
// Forbid copy constructor
WriteGuard(const WriteGuard& source);
RWLock* lock;
};
RWLock() : lock(0), blockedReaders(0), blockedWriters(0) RWLock() : lock(0), blockedReaders(0), blockedWriters(0)
{ {
readers_semaphore = CreateSemaphore(NULL, 0 /*initial count*/, readers_semaphore = CreateSemaphore(NULL, 0 /*initial count*/,
@ -217,11 +157,8 @@ public:
if (lock.exchangeAdd(LOCK_WRITER_OFFSET) == -LOCK_WRITER_OFFSET) if (lock.exchangeAdd(LOCK_WRITER_OFFSET) == -LOCK_WRITER_OFFSET)
unblockWaiting(); unblockWaiting();
} }
};
} // namespace Firebird
#else #else
#ifdef MULTI_THREAD #ifdef MULTI_THREAD
@ -292,9 +229,6 @@ public:
if (rw_unlock(&lock)) if (rw_unlock(&lock))
system_call_failed::raise("rw_unlock"); system_call_failed::raise("rw_unlock");
} }
};
} // namespace Firebird
@ -373,9 +307,6 @@ public:
if (pthread_rwlock_unlock(&lock)) if (pthread_rwlock_unlock(&lock))
system_call_failed::raise("pthread_rwlock_unlock"); system_call_failed::raise("pthread_rwlock_unlock");
} }
};
} // namespace Firebird
#endif /*solaris threading (not posix)*/ #endif /*solaris threading (not posix)*/
@ -399,15 +330,75 @@ public:
bool tryBeginWrite() { return true; } bool tryBeginWrite() { return true; }
void beginWrite() { } void beginWrite() { }
void endWrite() { } void endWrite() { }
};
} // namespace Firebird
#endif /*MULTI_THREAD*/ #endif /*MULTI_THREAD*/
#endif /*!WIN_NT*/ #endif /*!WIN_NT*/
namespace Firebird { // common for all platforms part of class
public:
// RAII holder of begin/end read
class ReadGuard
{
public:
explicit ReadGuard(RWLock& alock)
: lock(&alock)
{
lock->beginRead();
}
~ReadGuard()
{
release();
}
void release()
{
if (lock)
{
lock->endRead();
lock = NULL;
}
}
private:
// Forbid copy constructor
ReadGuard(const ReadGuard& source);
RWLock* lock;
};
// RAII holder of begin/end write
class WriteGuard
{
public:
explicit WriteGuard(RWLock& alock)
: lock(&alock)
{
lock->beginWrite();
}
~WriteGuard()
{
release();
}
void release()
{
if (lock)
{
lock->endWrite();
lock = NULL;
}
}
private:
// Forbid copy constructor
WriteGuard(const WriteGuard& source);
RWLock* lock;
};
};
// RAII holder of read lock // RAII holder of read lock
class ReadLockGuard { class ReadLockGuard {

View File

@ -119,7 +119,7 @@ bool LCICU_setup_attributes(const ASCII* name, const ASCII* charSetName, const A
if (len > 8 && strcmp(name + len - 8, "_UNICODE") == 0) if (len > 8 && strcmp(name + len - 8, "_UNICODE") == 0)
{ {
AutoPtr<charset, Jrd::CharSet::Delete> cs = new charset; AutoPtr<charset, Jrd::CharSet::Delete> cs(new charset);
memset(cs, 0, sizeof(*cs)); memset(cs, 0, sizeof(*cs));
// test if that charset exist // test if that charset exist

View File

@ -368,7 +368,7 @@ Firebird::string IntlManager::getConfigInfo(const ConfObj& confObj)
if (configInfo.hasData()) if (configInfo.hasData())
configInfo.append(";"); configInfo.append(";");
configInfo.append(string(el->name) + "=" + values); configInfo.append(string(el->name.c_str()) + "=" + values);
} }
return configInfo; return configInfo;

View File

@ -475,7 +475,7 @@ bool IntlUtil::readOneChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR* end,
bool IntlUtil::setupIcuAttributes(charset* cs, const string& specificAttributes, bool IntlUtil::setupIcuAttributes(charset* cs, const string& specificAttributes,
const string& configInfo, string& newSpecificAttributes) const string& configInfo, string& newSpecificAttributes)
{ {
AutoPtr<Jrd::CharSet> charSet = Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs); AutoPtr<Jrd::CharSet> charSet(Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs));
IntlUtil::SpecificAttributesMap map; IntlUtil::SpecificAttributesMap map;
if (!IntlUtil::parseSpecificAttributes(charSet, specificAttributes.length(), if (!IntlUtil::parseSpecificAttributes(charSet, specificAttributes.length(),

View File

@ -1361,7 +1361,7 @@ static dsc* evlHash(Jrd::thread_db* tdbb, SysFunction* function, Jrd::jrd_nod* a
{ {
impure->vlu_misc.vlu_int64 = (impure->vlu_misc.vlu_int64 << 4) + *address; impure->vlu_misc.vlu_int64 = (impure->vlu_misc.vlu_int64 << 4) + *address;
SINT64 n = impure->vlu_misc.vlu_int64 & 0xF000000000000000i64; SINT64 n = impure->vlu_misc.vlu_int64 & CONST64(0xF000000000000000);
if (n) if (n)
impure->vlu_misc.vlu_int64 ^= n >> 56; impure->vlu_misc.vlu_int64 ^= n >> 56;
impure->vlu_misc.vlu_int64 &= ~n; impure->vlu_misc.vlu_int64 &= ~n;
@ -1629,7 +1629,7 @@ static dsc* evlOverlay(Jrd::thread_db* tdbb, SysFunction* function, Jrd::jrd_nod
if (!value->isBlob() && !placing->isBlob()) if (!value->isBlob() && !placing->isBlob())
{ {
if (len1 - length + len2 > MAX_COLUMN_SIZE - sizeof(USHORT)) if (len1 - length + len2 > static_cast<signed>(MAX_COLUMN_SIZE - sizeof(USHORT)))
status_exception::raise(isc_arith_except, 0); status_exception::raise(isc_arith_except, 0);
dsc desc; dsc desc;
@ -1716,7 +1716,7 @@ static dsc* evlPad(Jrd::thread_db* tdbb, SysFunction* function, Jrd::jrd_nod* ar
const dsc* padLenDsc = EVL_expr(tdbb, args->nod_arg[1]); const dsc* padLenDsc = EVL_expr(tdbb, args->nod_arg[1]);
if (request->req_flags & req_null) // return NULL if padLenDsc is NULL if (request->req_flags & req_null) // return NULL if padLenDsc is NULL
return NULL; return NULL;
SLONG padLen = MOV_get_long(padLenDsc, 0); ULONG padLen = MOV_get_long(padLenDsc, 0);
const dsc* value2 = NULL; const dsc* value2 = NULL;
if (args->nod_count >= 3) if (args->nod_count >= 3)
@ -1732,7 +1732,7 @@ static dsc* evlPad(Jrd::thread_db* tdbb, SysFunction* function, Jrd::jrd_nod* ar
MoveBuffer buffer1; MoveBuffer buffer1;
UCHAR* address1; UCHAR* address1;
ULONG length1 = MOV_make_string2(tdbb, value1, ttype, &address1, buffer1, false); ULONG length1 = MOV_make_string2(tdbb, value1, ttype, &address1, buffer1, false);
SLONG charLength1 = cs->length(length1, address1, true); ULONG charLength1 = cs->length(length1, address1, true);
MoveBuffer buffer2; MoveBuffer buffer2;
UCHAR* address2; UCHAR* address2;
@ -1746,7 +1746,7 @@ static dsc* evlPad(Jrd::thread_db* tdbb, SysFunction* function, Jrd::jrd_nod* ar
else else
length2 = MOV_make_string2(tdbb, value2, ttype, &address2, buffer2, false); length2 = MOV_make_string2(tdbb, value2, ttype, &address2, buffer2, false);
SLONG charLength2 = cs->length(length2, address2, true); ULONG charLength2 = cs->length(length2, address2, true);
blb* newBlob = NULL; blb* newBlob = NULL;
@ -2062,9 +2062,9 @@ static dsc* evlReplace(Jrd::thread_db* tdbb, SysFunction* function, Jrd::jrd_nod
// make descriptor for return value // make descriptor for return value
if (!firstBlob) if (!firstBlob)
{ {
int searchedLen = canonicals[0].getCount() / canonicalWidth; unsigned int searchedLen = canonicals[0].getCount() / canonicalWidth;
int findLen = canonicals[1].getCount() / canonicalWidth; unsigned int findLen = canonicals[1].getCount() / canonicalWidth;
int replacementLen = lengths[2] / cs->minBytesPerChar(); unsigned int replacementLen = lengths[2] / cs->minBytesPerChar();
USHORT len = MIN(MAX_COLUMN_SIZE, cs->maxBytesPerChar() * USHORT len = MIN(MAX_COLUMN_SIZE, cs->maxBytesPerChar() *
MAX(searchedLen, searchedLen + MAX(searchedLen, searchedLen +
@ -2427,15 +2427,20 @@ SysFunction::SysFunction(const char* s, int minCount, int maxCount, MakeFunc mf,
#define SF(a, b, c, d, e, f) {a, b, c, d, e, f} #define SF(a, b, c, d, e, f) {a, b, c, d, e, f}
#endif #endif
#ifdef _MSC_VER
typedef StdMathFunc VoidPtrStdMathFunc;
#else
typedef void* VoidPtrStdMathFunc;
#endif
SysFunction SysFunction::functions[] = SysFunction SysFunction::functions[] =
{ {
SF("ABS", 1, 1, makeAbs, evlAbs, NULL), SF("ABS", 1, 1, makeAbs, evlAbs, NULL),
SF("ACOS", 1, 1, makeDoubleResult, evlStdMath, (StdMathFunc) acos), SF("ACOS", 1, 1, makeDoubleResult, evlStdMath, (VoidPtrStdMathFunc) acos),
SF("ASCII_CHAR", 1, 1, makeAsciiChar, evlAsciiChar, NULL), SF("ASCII_CHAR", 1, 1, makeAsciiChar, evlAsciiChar, NULL),
SF("ASCII_VAL", 1, 1, makeShortResult, evlAsciiVal, NULL), SF("ASCII_VAL", 1, 1, makeShortResult, evlAsciiVal, NULL),
SF("ASIN", 1, 1, makeDoubleResult, evlStdMath, (StdMathFunc) asin), SF("ASIN", 1, 1, makeDoubleResult, evlStdMath, (VoidPtrStdMathFunc) asin),
SF("ATAN", 1, 1, makeDoubleResult, evlStdMath, (StdMathFunc) atan), SF("ATAN", 1, 1, makeDoubleResult, evlStdMath, (VoidPtrStdMathFunc) atan),
SF("ATAN2", 2, 2, makeDoubleResult, evlAtan2, NULL), SF("ATAN2", 2, 2, makeDoubleResult, evlAtan2, NULL),
SF("BIN_AND", 1, -1, makeBin, evlBin, (void*) funBinAnd), SF("BIN_AND", 1, -1, makeBin, evlBin, (void*) funBinAnd),
SF("BIN_OR", 1, -1, makeBin, evlBin, (void*) funBinOr), SF("BIN_OR", 1, -1, makeBin, evlBin, (void*) funBinOr),
@ -2444,9 +2449,9 @@ SysFunction SysFunction::functions[] =
SF("BIN_XOR", 1, -1, makeBin, evlBin, (void*) funBinXor), SF("BIN_XOR", 1, -1, makeBin, evlBin, (void*) funBinXor),
SF("CEIL", 1, 1, makeCeilFloor, evlCeil, NULL), SF("CEIL", 1, 1, makeCeilFloor, evlCeil, NULL),
SF("CEILING", 1, 1, makeCeilFloor, evlCeil, NULL), SF("CEILING", 1, 1, makeCeilFloor, evlCeil, NULL),
SF("COS", 1, 1, makeDoubleResult, evlStdMath, (StdMathFunc) cos), SF("COS", 1, 1, makeDoubleResult, evlStdMath, (VoidPtrStdMathFunc) cos),
SF("COSH", 1, 1, makeDoubleResult, evlStdMath, (StdMathFunc) cosh), SF("COSH", 1, 1, makeDoubleResult, evlStdMath, (VoidPtrStdMathFunc) cosh),
SF("COT", 1, 1, makeDoubleResult, evlStdMath, (StdMathFunc) cot), SF("COT", 1, 1, makeDoubleResult, evlStdMath, (VoidPtrStdMathFunc) cot),
SF("DATEADD", 3, 3, makeDateAdd, evlDateAdd, NULL), SF("DATEADD", 3, 3, makeDateAdd, evlDateAdd, NULL),
SF("DATEDIFF", 3, 3, makeInt64Result, evlDateDiff, NULL), SF("DATEDIFF", 3, 3, makeInt64Result, evlDateDiff, NULL),
SF("EXP", 1, 1, makeDoubleResult, evlExp, NULL), SF("EXP", 1, 1, makeDoubleResult, evlExp, NULL),
@ -2456,7 +2461,7 @@ SysFunction SysFunction::functions[] =
SF("LEFT", 2, 2, makeLeftRight, evlLeft, NULL), SF("LEFT", 2, 2, makeLeftRight, evlLeft, NULL),
SF("LN", 1, 1, makeDoubleResult, evlLn, NULL), SF("LN", 1, 1, makeDoubleResult, evlLn, NULL),
SF("LOG", 2, 2, makeDoubleResult, evlLog, NULL), SF("LOG", 2, 2, makeDoubleResult, evlLog, NULL),
SF("LOG10", 1, 1, makeDoubleResult, evlStdMath, (StdMathFunc) log10), SF("LOG10", 1, 1, makeDoubleResult, evlStdMath, (VoidPtrStdMathFunc) log10),
SF("LPAD", 2, 3, makePad, evlPad, (void*) funLPad), SF("LPAD", 2, 3, makePad, evlPad, (void*) funLPad),
SF("MAXVALUE", 1, -1, makeFromListResult, evlMaxMinValue, (void*) funMaxValue), SF("MAXVALUE", 1, -1, makeFromListResult, evlMaxMinValue, (void*) funMaxValue),
SF("MINVALUE", 1, -1, makeFromListResult, evlMaxMinValue, (void*) funMinValue), SF("MINVALUE", 1, -1, makeFromListResult, evlMaxMinValue, (void*) funMinValue),
@ -2472,13 +2477,13 @@ SysFunction SysFunction::functions[] =
SF("ROUND", 2, 2, makeRound, evlRound, NULL), SF("ROUND", 2, 2, makeRound, evlRound, NULL),
SF("RPAD", 2, 3, makePad, evlPad, (void*) funRPad), SF("RPAD", 2, 3, makePad, evlPad, (void*) funRPad),
SF("SIGN", 1, 1, makeShortResult, evlSign, NULL), SF("SIGN", 1, 1, makeShortResult, evlSign, NULL),
SF("SIN", 1, 1, makeDoubleResult, evlStdMath, (StdMathFunc) sin), SF("SIN", 1, 1, makeDoubleResult, evlStdMath, (VoidPtrStdMathFunc) sin),
SF("SINH", 1, 1, makeDoubleResult, evlStdMath, (StdMathFunc) sinh), SF("SINH", 1, 1, makeDoubleResult, evlStdMath, (VoidPtrStdMathFunc) sinh),
SF("SQRT", 1, 1, makeDoubleResult, evlSqrt, NULL), SF("SQRT", 1, 1, makeDoubleResult, evlSqrt, NULL),
SF("TAN", 1, 1, makeDoubleResult, evlStdMath, (StdMathFunc) tan), SF("TAN", 1, 1, makeDoubleResult, evlStdMath, (VoidPtrStdMathFunc) tan),
SF("TANH", 1, 1, makeDoubleResult, evlStdMath, (StdMathFunc) tanh), SF("TANH", 1, 1, makeDoubleResult, evlStdMath, (VoidPtrStdMathFunc) tanh),
SF("TRUNC", 1, 1, makeTrunc, evlTrunc, NULL), SF("TRUNC", 1, 1, makeTrunc, evlTrunc, NULL),
SF("", 0, NULL, NULL, NULL, NULL) SF("", 0, 0, NULL, NULL, NULL)
}; };

View File

@ -1047,6 +1047,13 @@ void GDS_breakpoint(int);
#define STRINGIZE_AUX(x) #x #define STRINGIZE_AUX(x) #x
#define STRINGIZE(x) STRINGIZE_AUX(x) #define STRINGIZE(x) STRINGIZE_AUX(x)
#ifdef _MSC_VER
#define CONST64(a) (a##i64)
#else
#define CONST64(a) (a##L)
#endif
/* switch name and state table. This structure should be used in all /* switch name and state table. This structure should be used in all
* command line tools to facilitate parsing options.*/ * command line tools to facilitate parsing options.*/
struct in_sw_tab_t { struct in_sw_tab_t {

View File

@ -1235,6 +1235,7 @@ static INTL_BOOL cs_utf32_well_formed(charset* cs,
} }
#ifdef NOT_USED_OR_REPLACED
static ULONG cvt_ascii_to_unicode(csconvert* obj, ULONG nSrc, const UCHAR* pSrc, static ULONG cvt_ascii_to_unicode(csconvert* obj, ULONG nSrc, const UCHAR* pSrc,
ULONG nDest, USHORT* pDest, ULONG nDest, USHORT* pDest,
USHORT* err_code, ULONG* err_position) USHORT* err_code, ULONG* err_position)
@ -1321,6 +1322,7 @@ static ULONG cvt_unicode_to_ascii(csconvert* obj, ULONG nSrc, const USHORT* pSrc
return ((pDest - pStart) * sizeof(*pDest)); return ((pDest - pStart) * sizeof(*pDest));
} }
#endif //NOT_USED_OR_REPLACED
static ULONG cvt_none_to_unicode(csconvert* obj, ULONG nSrc, const UCHAR* pSrc, static ULONG cvt_none_to_unicode(csconvert* obj, ULONG nSrc, const UCHAR* pSrc,
@ -1843,7 +1845,7 @@ ULONG INTL_builtin_setup_attributes(const ASCII* textTypeName, const ASCII* char
// the preprocessor, but this is a task for another day. // the preprocessor, but this is a task for another day.
if (strstr(textTypeName, "UNICODE") && strcmp(textTypeName, "UNICODE_FSS") != 0) if (strstr(textTypeName, "UNICODE") && strcmp(textTypeName, "UNICODE_FSS") != 0)
{ {
Firebird::AutoPtr<charset, Jrd::CharSet::Delete> cs = new charset; Firebird::AutoPtr<charset, Jrd::CharSet::Delete> cs(new charset);
memset(cs, 0, sizeof(*cs)); memset(cs, 0, sizeof(*cs));
// test if that charset exists // test if that charset exists

View File

@ -34,7 +34,7 @@
#include "../common/classes/GenericMap.h" #include "../common/classes/GenericMap.h"
#include "../common/classes/init.h" #include "../common/classes/init.h"
#include "../common/classes/objects_array.h" #include "../common/classes/objects_array.h"
#include "../common/classes/RWLock.h" #include "../common/classes/rwlock.h"
#include "unicode/ustring.h" #include "unicode/ustring.h"
#include "unicode/uchar.h" #include "unicode/uchar.h"
#include "unicode/ucnv.h" #include "unicode/ucnv.h"
@ -118,7 +118,7 @@ static void getVersions(const string& configInfo, ObjectsArray<string>& versions
charset cs; charset cs;
IntlUtil::initAsciiCharset(&cs); IntlUtil::initAsciiCharset(&cs);
AutoPtr<CharSet> ascii = Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, &cs); AutoPtr<CharSet> ascii(Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, &cs));
IntlUtil::SpecificAttributesMap config; IntlUtil::SpecificAttributesMap config;
IntlUtil::parseSpecificAttributes(ascii, configInfo.length(), IntlUtil::parseSpecificAttributes(ascii, configInfo.length(),