mirror of https://gitee.com/bigwinds/arangodb
merge
This commit is contained in:
commit
abe2481363
|
@ -10072,7 +10072,7 @@ static v8::Handle<v8::Integer> PropertyQueryShapedJson (v8::Local<v8::String> na
|
|||
TRI_shape_access_t const* acc = TRI_FindAccessorVocShaper(shaper, sid, pid);
|
||||
|
||||
// key not found
|
||||
if (acc == 0 || acc->_resultSid == 0) {
|
||||
if (acc == 0 || acc->_resultSid == TRI_SHAPE_ILLEGAL) {
|
||||
return scope.Close(v8::Handle<v8::Integer>());
|
||||
}
|
||||
|
||||
|
|
|
@ -109,12 +109,12 @@ static TRI_shape_aid_t LookupAttributeByName (TRI_shaper_t* shaper,
|
|||
voc_shaper_t* s;
|
||||
void const* p;
|
||||
|
||||
assert(name != NULL);
|
||||
assert(name != nullptr);
|
||||
|
||||
s = (voc_shaper_t*) shaper;
|
||||
p = TRI_LookupByKeyAssociativeSynced(&s->_attributeNames, name);
|
||||
|
||||
if (p != NULL) {
|
||||
if (p != nullptr) {
|
||||
return ((TRI_df_attribute_marker_t const*) p)->_aid;
|
||||
}
|
||||
|
||||
|
@ -141,12 +141,12 @@ static TRI_shape_aid_t FindOrCreateAttributeByName (TRI_shaper_t* shaper,
|
|||
void const* p;
|
||||
void* f;
|
||||
|
||||
assert(name != NULL);
|
||||
assert(name != nullptr);
|
||||
|
||||
s = (voc_shaper_t*) shaper;
|
||||
p = TRI_LookupByKeyAssociativeSynced(&s->_attributeNames, name);
|
||||
|
||||
if (p != NULL) {
|
||||
if (p != nullptr) {
|
||||
return ((TRI_df_attribute_marker_t const*) p)->_aid;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ static TRI_shape_aid_t FindOrCreateAttributeByName (TRI_shaper_t* shaper,
|
|||
totalSize = (TRI_voc_size_t) (sizeof(TRI_df_attribute_marker_t) + n);
|
||||
mem = (char*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, totalSize, false);
|
||||
|
||||
if (mem == NULL) {
|
||||
if (mem == nullptr) {
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return 0;
|
||||
|
@ -164,7 +164,7 @@ static TRI_shape_aid_t FindOrCreateAttributeByName (TRI_shaper_t* shaper,
|
|||
|
||||
// marker points to mem, but has a different type
|
||||
marker = (TRI_df_attribute_marker_t*) mem;
|
||||
assert(marker != NULL);
|
||||
assert(marker != nullptr);
|
||||
|
||||
// init attribute marker
|
||||
TRI_InitMarker(mem, TRI_DF_MARKER_ATTRIBUTE, totalSize);
|
||||
|
@ -179,7 +179,7 @@ static TRI_shape_aid_t FindOrCreateAttributeByName (TRI_shaper_t* shaper,
|
|||
p = TRI_LookupByKeyAssociativeSynced(&s->_attributeNames, name);
|
||||
|
||||
// if the element appeared, return the aid
|
||||
if (p != NULL) {
|
||||
if (p != nullptr) {
|
||||
TRI_UnlockMutex(&s->_attributeLock);
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, mem);
|
||||
|
||||
|
@ -212,22 +212,22 @@ static TRI_shape_aid_t FindOrCreateAttributeByName (TRI_shaper_t* shaper,
|
|||
return 0;
|
||||
}
|
||||
|
||||
assert(result != NULL);
|
||||
assert(result != nullptr);
|
||||
|
||||
// update datafile info
|
||||
dfi = TRI_FindDatafileInfoPrimaryCollection(&s->_collection->base, fid, true);
|
||||
|
||||
if (dfi != NULL) {
|
||||
if (dfi != nullptr) {
|
||||
dfi->_numberAttributes++;
|
||||
dfi->_sizeAttributes += (int64_t) TRI_DF_ALIGN_BLOCK(totalSize);
|
||||
}
|
||||
|
||||
f = TRI_InsertKeyAssociativeSynced(&s->_attributeIds, &aid, result, false);
|
||||
assert(f == NULL);
|
||||
assert(f == nullptr);
|
||||
|
||||
// enter into the dictionaries
|
||||
f = TRI_InsertKeyAssociativeSynced(&s->_attributeNames, name, result, false);
|
||||
assert(f == NULL);
|
||||
assert(f == nullptr);
|
||||
|
||||
// ...........................................................................
|
||||
// and release the lock
|
||||
|
@ -279,8 +279,8 @@ static char const* LookupAttributeId (TRI_shaper_t* shaper,
|
|||
|
||||
void const* p = TRI_LookupByKeyAssociativeSynced(&s->_attributeIds, &aid);
|
||||
|
||||
if (p == NULL) {
|
||||
return NULL;
|
||||
if (p == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return static_cast<char const*>(p) + sizeof(TRI_df_attribute_marker_t);
|
||||
|
@ -319,9 +319,9 @@ static bool EqualElementShape (TRI_associative_synced_t* array,
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief finds a shape
|
||||
/// if the function returns non-NULL, the return value is a pointer to an
|
||||
/// if the function returns non-nullptr, the return value is a pointer to an
|
||||
/// already existing shape and the value must not be freed
|
||||
/// if the function returns NULL, it has not found the shape and was not able
|
||||
/// if the function returns nullptr, it has not found the shape and was not able
|
||||
/// to create it. The value must then be freed by the caller
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -345,12 +345,12 @@ static TRI_shape_t const* FindShape (TRI_shaper_t* shaper,
|
|||
|
||||
found = TRI_LookupBasicShapeShaper(shape);
|
||||
|
||||
if (found == NULL) {
|
||||
if (found == nullptr) {
|
||||
found = static_cast<TRI_shape_t const*>(TRI_LookupByElementAssociativeSynced(&s->_shapeDictionary, shape));
|
||||
}
|
||||
|
||||
// shape found, free argument and return
|
||||
if (found != NULL) {
|
||||
if (found != nullptr) {
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, shape);
|
||||
|
||||
return found;
|
||||
|
@ -365,14 +365,14 @@ static TRI_shape_t const* FindShape (TRI_shaper_t* shaper,
|
|||
totalSize = (TRI_voc_size_t) (sizeof(TRI_df_shape_marker_t) + shape->_size);
|
||||
mem = (char*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, totalSize, false);
|
||||
|
||||
if (mem == NULL) {
|
||||
if (mem == nullptr) {
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
marker = (TRI_df_shape_marker_t*) mem;
|
||||
assert(marker != NULL);
|
||||
assert(marker != nullptr);
|
||||
|
||||
TRI_InitMarker(mem, TRI_DF_MARKER_SHAPE, totalSize);
|
||||
|
||||
|
@ -418,15 +418,15 @@ static TRI_shape_t const* FindShape (TRI_shaper_t* shaper,
|
|||
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, mem);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
assert(result != NULL);
|
||||
assert(result != nullptr);
|
||||
|
||||
// update datafile info
|
||||
dfi = TRI_FindDatafileInfoPrimaryCollection(&s->_collection->base, fid, true);
|
||||
|
||||
if (dfi != NULL) {
|
||||
if (dfi != nullptr) {
|
||||
dfi->_numberShapes++;
|
||||
dfi->_sizeShapes += (int64_t) TRI_DF_ALIGN_BLOCK(totalSize);
|
||||
}
|
||||
|
@ -435,10 +435,10 @@ static TRI_shape_t const* FindShape (TRI_shaper_t* shaper,
|
|||
l = (TRI_shape_t*) (((char*) result) + sizeof(TRI_df_shape_marker_t));
|
||||
|
||||
f = TRI_InsertKeyAssociativeSynced(&s->_shapeIds, &l->_sid, l, false);
|
||||
assert(f == NULL);
|
||||
assert(f == nullptr);
|
||||
|
||||
f = TRI_InsertElementAssociativeSynced(&s->_shapeDictionary, l, false);
|
||||
assert(f == NULL);
|
||||
assert(f == nullptr);
|
||||
|
||||
TRI_UnlockMutex(&s->_shapeLock);
|
||||
|
||||
|
@ -491,7 +491,7 @@ static TRI_shape_t const* LookupShapeId (TRI_shaper_t* shaper,
|
|||
TRI_shape_sid_t sid) {
|
||||
TRI_shape_t const* shape = TRI_LookupSidBasicShapeShaper(sid);
|
||||
|
||||
if (shape == NULL) {
|
||||
if (shape == nullptr) {
|
||||
voc_shaper_t* s = (voc_shaper_t*) shaper;
|
||||
shape = static_cast<TRI_shape_t const*>(TRI_LookupByKeyAssociativeSynced(&s->_shapeIds, &sid));
|
||||
}
|
||||
|
@ -646,9 +646,9 @@ TRI_shaper_t* TRI_CreateVocShaper (TRI_vocbase_t* vocbase,
|
|||
TRI_document_collection_t* document) {
|
||||
voc_shaper_t* shaper = static_cast<voc_shaper_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(voc_shaper_t), false));
|
||||
|
||||
if (shaper == NULL) {
|
||||
if (shaper == nullptr) {
|
||||
// out of memory
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
shaper->_collection = document;
|
||||
|
@ -658,7 +658,7 @@ TRI_shaper_t* TRI_CreateVocShaper (TRI_vocbase_t* vocbase,
|
|||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, shaper);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
res = InitStep1VocShaper(shaper);
|
||||
|
@ -666,7 +666,7 @@ TRI_shaper_t* TRI_CreateVocShaper (TRI_vocbase_t* vocbase,
|
|||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_FreeShaper(&shaper->base);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
res = InitStep2VocShaper(shaper);
|
||||
|
@ -674,7 +674,7 @@ TRI_shaper_t* TRI_CreateVocShaper (TRI_vocbase_t* vocbase,
|
|||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_FreeVocShaper(&shaper->base);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// and return
|
||||
|
@ -688,7 +688,7 @@ TRI_shaper_t* TRI_CreateVocShaper (TRI_vocbase_t* vocbase,
|
|||
void TRI_DestroyVocShaper (TRI_shaper_t* s) {
|
||||
voc_shaper_t* shaper = (voc_shaper_t*) s;
|
||||
|
||||
assert(shaper != NULL);
|
||||
assert(shaper != nullptr);
|
||||
|
||||
TRI_DestroyAssociativeSynced(&shaper->_attributeNames);
|
||||
TRI_DestroyAssociativeSynced(&shaper->_attributeIds);
|
||||
|
@ -698,7 +698,7 @@ void TRI_DestroyVocShaper (TRI_shaper_t* s) {
|
|||
for (size_t i = 0; i < shaper->_accessors._nrAlloc; ++i) {
|
||||
TRI_shape_access_t* accessor = (TRI_shape_access_t*) shaper->_accessors._table[i];
|
||||
|
||||
if (accessor != NULL) {
|
||||
if (accessor != nullptr) {
|
||||
TRI_FreeShapeAccessor(accessor);
|
||||
}
|
||||
}
|
||||
|
@ -750,12 +750,12 @@ int TRI_MoveMarkerVocShaper (TRI_shaper_t* s,
|
|||
// remove the old marker
|
||||
// and re-insert the marker with the new pointer
|
||||
f = TRI_InsertKeyAssociativeSynced(&shaper->_shapeIds, &l->_sid, l, true);
|
||||
assert(f != NULL);
|
||||
assert(f != nullptr);
|
||||
|
||||
// same for the shape dictionary
|
||||
// delete and re-insert
|
||||
f = TRI_InsertElementAssociativeSynced(&shaper->_shapeDictionary, l, true);
|
||||
assert(f != NULL);
|
||||
assert(f != nullptr);
|
||||
|
||||
TRI_UnlockMutex(&shaper->_shapeLock);
|
||||
}
|
||||
|
@ -770,12 +770,12 @@ int TRI_MoveMarkerVocShaper (TRI_shaper_t* s,
|
|||
// are identical in old and new marker)
|
||||
// and re-insert same attribute with adjusted pointer
|
||||
f = TRI_InsertKeyAssociativeSynced(&shaper->_attributeNames, p, m, true);
|
||||
assert(f != NULL);
|
||||
assert(f != nullptr);
|
||||
|
||||
// same for attribute ids
|
||||
// delete and re-insert same attribute with adjusted pointer
|
||||
f = TRI_InsertKeyAssociativeSynced(&shaper->_attributeIds, &m->_aid, m, true);
|
||||
assert(f != NULL);
|
||||
assert(f != nullptr);
|
||||
|
||||
TRI_UnlockMutex(&shaper->_attributeLock);
|
||||
}
|
||||
|
@ -797,10 +797,10 @@ int TRI_InsertShapeVocShaper (TRI_shaper_t* s,
|
|||
LOG_TRACE("found shape %lu", (unsigned long) l->_sid);
|
||||
|
||||
f = TRI_InsertElementAssociativeSynced(&shaper->_shapeDictionary, l, false);
|
||||
assert(f == NULL);
|
||||
assert(f == nullptr);
|
||||
|
||||
f = TRI_InsertKeyAssociativeSynced(&shaper->_shapeIds, &l->_sid, l, false);
|
||||
assert(f == NULL);
|
||||
assert(f == nullptr);
|
||||
|
||||
if (shaper->_nextSid <= l->_sid) {
|
||||
shaper->_nextSid = l->_sid + 1;
|
||||
|
@ -824,7 +824,7 @@ int TRI_InsertAttributeVocShaper (TRI_shaper_t* s,
|
|||
|
||||
f = TRI_InsertKeyAssociativeSynced(&shaper->_attributeNames, p, m, false);
|
||||
|
||||
if (f != NULL) {
|
||||
if (f != nullptr) {
|
||||
char const* name = shaper->_collection->base.base._info._name;
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
@ -836,7 +836,7 @@ int TRI_InsertAttributeVocShaper (TRI_shaper_t* s,
|
|||
|
||||
f = TRI_InsertKeyAssociativeSynced(&shaper->_attributeIds, &m->_aid, m, false);
|
||||
|
||||
if (f != NULL) {
|
||||
if (f != nullptr) {
|
||||
char const* name = shaper->_collection->base.base._info._name;
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
@ -871,11 +871,11 @@ TRI_shape_access_t const* TRI_FindAccessorVocShaper (TRI_shaper_t* s,
|
|||
TRI_LockMutex(&shaper->_accessorLock);
|
||||
TRI_shape_access_t const* found = static_cast<TRI_shape_access_t const*>(TRI_LookupByElementAssociativePointer(&shaper->_accessors, &search));
|
||||
|
||||
if (found == NULL) {
|
||||
if (found == nullptr) {
|
||||
found = accessor = TRI_ShapeAccessor(&shaper->base, sid, pid);
|
||||
|
||||
// TRI_ShapeAccessor can return a NULL pointer
|
||||
if (found != NULL) {
|
||||
// TRI_ShapeAccessor can return a nullptr pointer
|
||||
if (found != nullptr) {
|
||||
TRI_InsertElementAssociativePointer(&shaper->_accessors, accessor, true);
|
||||
}
|
||||
}
|
||||
|
@ -900,7 +900,7 @@ bool TRI_ExtractShapedJsonVocShaper (TRI_shaper_t* shaper,
|
|||
|
||||
accessor = TRI_FindAccessorVocShaper(shaper, document->_sid, pid);
|
||||
|
||||
if (accessor == NULL) {
|
||||
if (accessor == nullptr) {
|
||||
LOG_TRACE("failed to get accessor for sid %lu and path %lu",
|
||||
(unsigned long) document->_sid,
|
||||
(unsigned long) pid);
|
||||
|
@ -908,22 +908,14 @@ bool TRI_ExtractShapedJsonVocShaper (TRI_shaper_t* shaper,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (sid != 0 && sid != accessor->_resultSid) {
|
||||
LOG_TRACE("expecting sid %lu for path %lu, got sid %lu",
|
||||
(unsigned long) sid,
|
||||
(unsigned long) pid,
|
||||
(unsigned long) accessor->_resultSid);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (accessor->_resultSid == 0) {
|
||||
if (accessor->_resultSid == TRI_SHAPE_ILLEGAL) {
|
||||
LOG_TRACE("expecting any object for path %lu, got nothing",
|
||||
(unsigned long) pid);
|
||||
|
||||
return false;
|
||||
}
|
||||
*shape = nullptr;
|
||||
|
||||
return sid == TRI_SHAPE_ILLEGAL;
|
||||
}
|
||||
|
||||
*shape = shaper->lookupShapeId(shaper, accessor->_resultSid);
|
||||
|
||||
|
@ -932,7 +924,17 @@ bool TRI_ExtractShapedJsonVocShaper (TRI_shaper_t* shaper,
|
|||
(unsigned long) pid,
|
||||
(unsigned long) accessor->_resultSid);
|
||||
|
||||
return sid == 0;
|
||||
*shape = nullptr;
|
||||
|
||||
return sid == TRI_SHAPE_ILLEGAL;
|
||||
}
|
||||
|
||||
if (sid != 0 && sid != accessor->_resultSid) {
|
||||
LOG_TRACE("expecting sid %lu for path %lu, got sid %lu",
|
||||
(unsigned long) sid,
|
||||
(unsigned long) pid,
|
||||
(unsigned long) accessor->_resultSid);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1124,7 +1126,7 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
int result;
|
||||
|
||||
// left is either a shaped json or a shaped sub object
|
||||
if (leftDocument != NULL) {
|
||||
if (leftDocument != nullptr) {
|
||||
ptr = (char const*) leftDocument->_data;
|
||||
|
||||
left._sid = leftObject->_sid;
|
||||
|
@ -1136,7 +1138,7 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
}
|
||||
|
||||
// right is either a shaped json or a shaped sub object
|
||||
if (rightDocument != NULL) {
|
||||
if (rightDocument != nullptr) {
|
||||
ptr = (char const*) rightDocument->_data;
|
||||
|
||||
right._sid = rightObject->_sid;
|
||||
|
@ -1158,7 +1160,7 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
rightShape = rightShaper->lookupShapeId(rightShaper, right._sid);
|
||||
}
|
||||
|
||||
if (leftShape == NULL || rightShape == NULL) {
|
||||
if (leftShape == nullptr || rightShape == nullptr) {
|
||||
LOG_ERROR("shape not found");
|
||||
assert(false);
|
||||
}
|
||||
|
@ -1196,7 +1198,7 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
} // end of case TRI_SHAPE_ILLEGAL
|
||||
|
||||
// .............................................................................
|
||||
// NULL
|
||||
// nullptr
|
||||
// .............................................................................
|
||||
|
||||
case TRI_SHAPE_NULL: {
|
||||
|
@ -1402,11 +1404,11 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
&rightElement);
|
||||
}
|
||||
|
||||
result = TRI_CompareShapeTypes(NULL,
|
||||
NULL,
|
||||
result = TRI_CompareShapeTypes(nullptr,
|
||||
nullptr,
|
||||
&leftElement,
|
||||
NULL,
|
||||
NULL,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&rightElement,
|
||||
leftShaper,
|
||||
rightShaper);
|
||||
|
@ -1489,11 +1491,11 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
break;
|
||||
}
|
||||
|
||||
result = TRI_CompareShapeTypes(NULL,
|
||||
NULL,
|
||||
result = TRI_CompareShapeTypes(nullptr,
|
||||
nullptr,
|
||||
&l->_value,
|
||||
NULL,
|
||||
NULL,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&r->_value,
|
||||
leftShaper,
|
||||
rightShaper);
|
||||
|
|
|
@ -104,6 +104,9 @@
|
|||
#define TRI_HAVE_STRTOLL 1
|
||||
#define TRI_HAVE_STRTOULL 1
|
||||
|
||||
#define TRI_srandom srandom
|
||||
#define TRI_random random
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief available features
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -263,6 +266,9 @@
|
|||
#define TRI_HAVE_STRTOLL 1
|
||||
#define TRI_HAVE_STRTOULL 1
|
||||
|
||||
#define TRI_srandom srand
|
||||
#define TRI_random rand
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief available features
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -441,6 +447,9 @@
|
|||
|
||||
#define TRI_HAVE_ANONYMOUS_MMAP 1
|
||||
|
||||
#define TRI_srandom srand
|
||||
#define TRI_random rand
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief alignment and limits
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -564,10 +573,21 @@
|
|||
|
||||
#define TRI_HAVE_WIN32_GLOBAL_MEMORY_STATUS 1
|
||||
|
||||
#define TRI_srandom srand
|
||||
#define TRI_random rand
|
||||
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#define snprintf _snprintf
|
||||
|
||||
#define usleep TRI_usleep
|
||||
#define sleep TRI_sleep
|
||||
#define fsync _commit
|
||||
#define isatty _isatty
|
||||
#define fileno _fileno
|
||||
#define putenv _putenv
|
||||
#define tzset _tzset
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief available features
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -601,15 +621,6 @@
|
|||
// has been redefined in win-utils.h
|
||||
// ..............................................................
|
||||
|
||||
#define usleep TRI_usleep
|
||||
#define sleep TRI_sleep
|
||||
#define srandom srand
|
||||
#define fsync _commit
|
||||
#define isatty _isatty
|
||||
#define fileno _fileno
|
||||
#define putenv _putenv
|
||||
#define tzset _tzset
|
||||
|
||||
typedef int ssize_t;
|
||||
|
||||
#ifndef va_copy
|
||||
|
|
|
@ -67,20 +67,18 @@ static unsigned long SeedRandom (void) {
|
|||
#ifdef TRI_HAVE_GETTIMEOFDAY
|
||||
struct timeval tv;
|
||||
int result;
|
||||
#endif
|
||||
|
||||
|
||||
seed = (unsigned long) time(0);
|
||||
|
||||
#ifdef TRI_HAVE_GETTIMEOFDAY
|
||||
result = gettimeofday(&tv, 0);
|
||||
|
||||
seed ^= (unsigned long)(tv.tv_sec);
|
||||
seed = (unsigned long)(tv.tv_sec);
|
||||
seed ^= (unsigned long)(tv.tv_usec);
|
||||
seed ^= (unsigned long)(result);
|
||||
#else
|
||||
seed = (unsigned long) time(0);
|
||||
#endif
|
||||
|
||||
seed ^= (unsigned long)(TRI_CurrentProcessId());
|
||||
seed ^= (unsigned long)(TRI_CurrentProcessId() << 8);
|
||||
seed ^= (unsigned long)(TRI_CurrentProcessId() << 16);
|
||||
seed ^= (unsigned long)(TRI_CurrentProcessId() << 24);
|
||||
seed ^= (unsigned long)(TRI_CurrentThreadId());
|
||||
|
||||
return seed;
|
||||
|
@ -106,15 +104,15 @@ static unsigned long SeedRandom (void) {
|
|||
uint16_t TRI_UInt16Random (void) {
|
||||
#if RAND_MAX == 2147483647
|
||||
|
||||
return rand() & 0xFFFF;
|
||||
return TRI_random() & 0xFFFF;
|
||||
|
||||
#else
|
||||
|
||||
uint32_t l1;
|
||||
uint32_t l2;
|
||||
|
||||
l1 = rand();
|
||||
l2 = rand();
|
||||
l1 = TRI_random();
|
||||
l2 = TRI_random();
|
||||
|
||||
return ((l1 & 0xFF) << 8) | (l2 & 0xFF);
|
||||
|
||||
|
@ -131,8 +129,8 @@ uint32_t TRI_UInt32Random (void) {
|
|||
uint32_t l1;
|
||||
uint32_t l2;
|
||||
|
||||
l1 = (uint32_t) rand();
|
||||
l2 = (uint32_t) rand();
|
||||
l1 = (uint32_t) TRI_random();
|
||||
l2 = (uint32_t) TRI_random();
|
||||
|
||||
return ((l1 & 0xFFFF) << 16) | (l2 & 0xFFFF);
|
||||
|
||||
|
@ -143,10 +141,10 @@ uint32_t TRI_UInt32Random (void) {
|
|||
uint32_t l3;
|
||||
uint32_t l4;
|
||||
|
||||
l1 = rand();
|
||||
l2 = rand();
|
||||
l3 = rand();
|
||||
l4 = rand();
|
||||
l1 = TRI_random();
|
||||
l2 = TRI_random();
|
||||
l3 = TRI_random();
|
||||
l4 = TRI_random();
|
||||
|
||||
return ((l1 & 0xFF) << 24) | ((l2 & 0xFF) << 16) | ((l3 & 0xFF) << 8) | (l4 & 0xFF);
|
||||
|
||||
|
@ -179,7 +177,8 @@ void TRI_InitialiseRandom (void) {
|
|||
return;
|
||||
}
|
||||
|
||||
srandom(SeedRandom());
|
||||
|
||||
TRI_srandom(SeedRandom());
|
||||
|
||||
Initialised = true;
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ static bool BytecodeShapeAccessor (TRI_shaper_t* shaper, TRI_shape_access_t* acc
|
|||
|
||||
TRI_DestroyVectorPointer(&ops);
|
||||
|
||||
accessor->_resultSid = 0;
|
||||
accessor->_resultSid = TRI_SHAPE_ILLEGAL;
|
||||
accessor->_code = NULL;
|
||||
|
||||
return true;
|
||||
|
@ -223,7 +223,7 @@ static bool BytecodeShapeAccessor (TRI_shaper_t* shaper, TRI_shape_access_t* acc
|
|||
else {
|
||||
TRI_DestroyVectorPointer(&ops);
|
||||
|
||||
accessor->_resultSid = 0;
|
||||
accessor->_resultSid = TRI_SHAPE_ILLEGAL;
|
||||
accessor->_code = NULL;
|
||||
|
||||
return true;
|
||||
|
@ -264,7 +264,7 @@ static bool ExecuteBytecodeShapeAccessor (TRI_shape_access_t const* accessor,
|
|||
TRI_shape_size_t pos;
|
||||
TRI_shape_size_t* offsetsV;
|
||||
|
||||
if (accessor->_resultSid == 0) {
|
||||
if (accessor->_resultSid == TRI_SHAPE_ILLEGAL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -386,7 +386,7 @@ void TRI_PrintShapeAccessor (TRI_shape_access_t* accessor) {
|
|||
(unsigned long) accessor->_sid,
|
||||
(unsigned long) accessor->_pid);
|
||||
|
||||
if (accessor->_resultSid == 0) {
|
||||
if (accessor->_resultSid == TRI_SHAPE_ILLEGAL) {
|
||||
printf(" result shape: -\n");
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue