1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-16 02:54:33 +02:00

* Updated breakpad to latest version.

This commit is contained in:
Christian Muehlhaeuser
2012-06-24 18:25:34 +02:00
parent 0a3a9a7e97
commit d3eb5c3f88
186 changed files with 9184 additions and 5835 deletions

View File

@@ -30,6 +30,7 @@
#include "common/linux/guid_creator.h"
#include <assert.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@@ -45,10 +46,6 @@
//
class GUIDGenerator {
public:
GUIDGenerator() {
srandom(time(NULL));
}
static u_int32_t BytesToUInt32(const u_int8_t bytes[]) {
return ((u_int32_t) bytes[0]
| ((u_int32_t) bytes[1] << 8)
@@ -63,7 +60,8 @@ class GUIDGenerator {
bytes[3] = (n >> 24) & 0xff;
}
bool CreateGUID(GUID *guid) const {
static bool CreateGUID(GUID *guid) {
InitOnce();
guid->data1 = random();
guid->data2 = (u_int16_t)(random());
guid->data3 = (u_int16_t)(random());
@@ -71,13 +69,23 @@ class GUIDGenerator {
UInt32ToBytes(&guid->data4[4], random());
return true;
}
private:
static void InitOnce() {
pthread_once(&once_control, &InitOnceImpl);
}
static void InitOnceImpl() {
srandom(time(NULL));
}
static pthread_once_t once_control;
};
// Guid generator.
const GUIDGenerator kGuidGenerator;
pthread_once_t GUIDGenerator::once_control = PTHREAD_ONCE_INIT;
bool CreateGUID(GUID *guid) {
return kGuidGenerator.CreateGUID(guid);
return GUIDGenerator::CreateGUID(guid);
}
// Parse guid to string.