More formatting fixes from clang tidy

This commit is contained in:
Ray Smith 2017-04-28 13:38:32 -07:00
parent 77015526fa
commit 7a116ce8bb
10 changed files with 181 additions and 191 deletions

View File

@ -1998,8 +1998,7 @@ bool TessBaseAPI::AdaptToWordStr(PageSegMode mode, const char* wordstr) {
for (t = 0; text[t] != '\0'; ++t) {
if (text[t] == '\n' || text[t] == ' ')
continue;
while (wordstr[w] == ' ')
++w;
while (wordstr[w] == ' ') ++w;
if (text[t] != wordstr[w])
break;
++w;

View File

@ -20,17 +20,17 @@
#undef X86_BUILD
#if defined(__x86_64__) || defined(__i386__) || defined(_WIN32)
# if !defined(ANDROID_BUILD)
# define X86_BUILD 1
# endif // !ANDROID_BUILD
#endif // x86 target
#if !defined(ANDROID_BUILD)
#define X86_BUILD 1
#endif // !ANDROID_BUILD
#endif // x86 target
#if defined(X86_BUILD)
# if defined(__GNUC__)
# include <cpuid.h>
# elif defined(_WIN32)
# include <intrin.h>
# endif
#if defined(__GNUC__)
#include <cpuid.h>
#elif defined(_WIN32)
#include <intrin.h>
#endif
#endif
SIMDDetect SIMDDetect::detector;
@ -43,16 +43,17 @@ bool SIMDDetect::sse_available_;
// Constructor.
// Tests the architecture in a system-dependent way to detect AVX, SSE and
// any other available SIMD equipment.
// __GNUC__ is also defined by compilers that include GNU extensions such as clang.
// __GNUC__ is also defined by compilers that include GNU extensions such as
// clang.
SIMDDetect::SIMDDetect() {
#if defined(X86_BUILD)
# if defined(__GNUC__)
#if defined(__GNUC__)
unsigned int eax, ebx, ecx, edx;
if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) != 0) {
sse_available_ = (ecx & 0x00080000) != 0;
avx_available_ = (ecx & 0x10000000) != 0;
}
# elif defined(_WIN32)
#elif defined(_WIN32)
int cpuInfo[4];
__cpuid(cpuInfo, 0);
if (cpuInfo[0] >= 1) {
@ -60,8 +61,8 @@ SIMDDetect::SIMDDetect() {
sse_available_ = (cpuInfo[2] & 0x00080000) != 0;
avx_available_ = (cpuInfo[2] & 0x10000000) != 0;
}
# else
# error "I don't know how to test for SIMD with this compiler"
# endif
#endif // X86_BUILD
#else
#error "I don't know how to test for SIMD with this compiler"
#endif
#endif // X86_BUILD
}

View File

@ -23,13 +23,9 @@
class SIMDDetect {
public:
// Returns true if AVX is available on this system.
static inline bool IsAVXAvailable() {
return detector.avx_available_;
}
static inline bool IsAVXAvailable() { return detector.avx_available_; }
// Returns true if SSE4.1 is available on this system.
static inline bool IsSSEAvailable() {
return detector.sse_available_;
}
static inline bool IsSSEAvailable() { return detector.sse_available_; }
private:
// Constructor, must set all static member variables.

View File

@ -203,8 +203,8 @@ class Tesseract : public Wordrec {
pix_original_ = original_pix;
// Clone to sublangs as well.
for (int i = 0; i < sub_langs_.size(); ++i)
sub_langs_[i]->set_pix_original(
original_pix ? pixClone(original_pix) : nullptr);
sub_langs_[i]->set_pix_original(original_pix ? pixClone(original_pix)
: nullptr);
}
// Returns a pointer to a Pix representing the best available (original) image
// of the page. Can be of any bit depth, but never color-mapped, as that has

View File

@ -44,7 +44,7 @@ class DebugPixa {
// The collection of images to put in the PDF.
Pixa* pixa_;
// The fonts used to draw text captions.
L_BMF* fonts_;
L_Bmf* fonts_;
};
} // namespace tesseract

View File

@ -235,7 +235,7 @@ enum PageIteratorLevel {
*
* JUSTIFICATION_RIGHT
* Each line, except possibly the first, is flush to the same right tab stop.
*/
*/
enum ParagraphJustification {
JUSTIFICATION_UNKNOWN,
JUSTIFICATION_LEFT,

View File

@ -363,28 +363,28 @@ static int tvfscanf(FILE* stream, const char *format, va_list ap) {
case 'p': // Pointer
rank = RANK_PTR;
base = 0;
goto scan_int;
goto scan_int;
case 'i': // Base-independent integer
base = 0;
goto scan_int;
goto scan_int;
case 'd': // Decimal integer
base = 10;
goto scan_int;
goto scan_int;
case 'o': // Octal integer
base = 8;
goto scan_int;
goto scan_int;
case 'u': // Unsigned decimal integer
base = 10;
goto scan_int;
goto scan_int;
case 'x': // Hexadecimal integer
case 'X':
base = 16;
goto scan_int;
goto scan_int;
case 'n': // Number of characters consumed
val = ftell(stream) - start_off;

View File

@ -84,32 +84,29 @@ cl_mem pixThBuffer; //output from thresholdtopix calculation
cl_int clStatus;
KernelEnv rEnv;
#define DS_TAG_VERSION "<version>"
#define DS_TAG_VERSION_END "</version>"
#define DS_TAG_DEVICE "<device>"
#define DS_TAG_DEVICE_END "</device>"
#define DS_TAG_SCORE "<score>"
#define DS_TAG_SCORE_END "</score>"
#define DS_TAG_DEVICE_TYPE "<type>"
#define DS_TAG_DEVICE_TYPE_END "</type>"
#define DS_TAG_DEVICE_NAME "<name>"
#define DS_TAG_DEVICE_NAME_END "</name>"
#define DS_TAG_DEVICE_DRIVER_VERSION "<driver>"
#define DS_TAG_DEVICE_DRIVER_VERSION_END "</driver>"
#define DS_TAG_VERSION "<version>"
#define DS_TAG_VERSION_END "</version>"
#define DS_TAG_DEVICE "<device>"
#define DS_TAG_DEVICE_END "</device>"
#define DS_TAG_SCORE "<score>"
#define DS_TAG_SCORE_END "</score>"
#define DS_TAG_DEVICE_TYPE "<type>"
#define DS_TAG_DEVICE_TYPE_END "</type>"
#define DS_TAG_DEVICE_NAME "<name>"
#define DS_TAG_DEVICE_NAME_END "</name>"
#define DS_TAG_DEVICE_DRIVER_VERSION "<driver>"
#define DS_TAG_DEVICE_DRIVER_VERSION_END "</driver>"
#define DS_DEVICE_NATIVE_CPU_STRING "native_cpu"
#define DS_DEVICE_NATIVE_CPU_STRING "native_cpu"
#define DS_DEVICE_NAME_LENGTH 256
typedef enum {
DS_EVALUATE_ALL,
DS_EVALUATE_NEW_ONLY
} ds_evaluation_type;
typedef enum { DS_EVALUATE_ALL, DS_EVALUATE_NEW_ONLY } ds_evaluation_type;
typedef struct {
unsigned int numDevices;
ds_device* devices;
const char* version;
unsigned int numDevices;
ds_device *devices;
const char *version;
} ds_profile;
typedef enum {
@ -130,11 +127,11 @@ typedef enum {
// device->score) update the data size of score. The encoding and the format
// of the score data is implementation defined. The function should return
// DS_SUCCESS if there's no error to be reported.
typedef ds_status (*ds_perf_evaluator)(ds_device* device, void* data);
typedef ds_status (*ds_perf_evaluator)(ds_device *device, void *data);
// deallocate memory used by score
typedef ds_status (*ds_score_release)(void* score);
static ds_status releaseDSProfile(ds_profile* profile, ds_score_release sr) {
typedef ds_status (*ds_score_release)(void *score);
static ds_status releaseDSProfile(ds_profile *profile, ds_score_release sr) {
ds_status status = DS_SUCCESS;
if (profile != nullptr) {
if (profile->devices != nullptr && sr != nullptr) {
@ -143,8 +140,7 @@ static ds_status releaseDSProfile(ds_profile* profile, ds_score_release sr) {
free(profile->devices[i].oclDeviceName);
free(profile->devices[i].oclDriverVersion);
status = sr(profile->devices[i].score);
if (status != DS_SUCCESS)
break;
if (status != DS_SUCCESS) break;
}
free(profile->devices);
}
@ -153,18 +149,18 @@ static ds_status releaseDSProfile(ds_profile* profile, ds_score_release sr) {
return status;
}
static ds_status initDSProfile(ds_profile** p, const char* version) {
static ds_status initDSProfile(ds_profile **p, const char *version) {
int numDevices;
cl_uint numPlatforms;
cl_platform_id* platforms = nullptr;
cl_device_id* devices = nullptr;
cl_platform_id *platforms = nullptr;
cl_device_id *devices = nullptr;
ds_status status = DS_SUCCESS;
unsigned int next;
unsigned int i;
if (p == nullptr) return DS_INVALID_PROFILE;
ds_profile* profile = (ds_profile*)malloc(sizeof(ds_profile));
ds_profile *profile = (ds_profile *)malloc(sizeof(ds_profile));
if (profile == nullptr) return DS_MEMORY_ERROR;
memset(profile, 0, sizeof(ds_profile));
@ -172,7 +168,7 @@ static ds_status initDSProfile(ds_profile** p, const char* version) {
clGetPlatformIDs(0, nullptr, &numPlatforms);
if (numPlatforms > 0) {
platforms = (cl_platform_id*)malloc(numPlatforms*sizeof(cl_platform_id));
platforms = (cl_platform_id *)malloc(numPlatforms * sizeof(cl_platform_id));
if (platforms == nullptr) {
status = DS_MEMORY_ERROR;
goto cleanup;
@ -184,26 +180,27 @@ static ds_status initDSProfile(ds_profile** p, const char* version) {
for (i = 0; i < (unsigned int)numPlatforms; i++) {
cl_uint num;
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0, nullptr, &num);
numDevices+=num;
numDevices += num;
}
if (numDevices > 0) {
devices = (cl_device_id*)malloc(numDevices * sizeof(cl_device_id));
devices = (cl_device_id *)malloc(numDevices * sizeof(cl_device_id));
if (devices == nullptr) {
status = DS_MEMORY_ERROR;
goto cleanup;
}
}
profile->numDevices = numDevices+1; // +1 to numDevices to include the native CPU
profile->numDevices =
numDevices + 1; // +1 to numDevices to include the native CPU
profile->devices =
(ds_device*)malloc(profile->numDevices * sizeof(ds_device));
(ds_device *)malloc(profile->numDevices * sizeof(ds_device));
if (profile->devices == nullptr) {
profile->numDevices = 0;
status = DS_MEMORY_ERROR;
goto cleanup;
}
memset(profile->devices, 0, profile->numDevices*sizeof(ds_device));
memset(profile->devices, 0, profile->numDevices * sizeof(ds_device));
next = 0;
for (i = 0; i < (unsigned int)numPlatforms; i++) {
@ -220,14 +217,14 @@ static ds_status initDSProfile(ds_profile** p, const char* version) {
clGetDeviceInfo(profile->devices[next].oclDeviceID, CL_DEVICE_NAME,
DS_DEVICE_NAME_LENGTH, &buffer, nullptr);
length = strlen(buffer);
profile->devices[next].oclDeviceName = (char*)malloc(length+1);
memcpy(profile->devices[next].oclDeviceName, buffer, length+1);
profile->devices[next].oclDeviceName = (char *)malloc(length + 1);
memcpy(profile->devices[next].oclDeviceName, buffer, length + 1);
clGetDeviceInfo(profile->devices[next].oclDeviceID, CL_DRIVER_VERSION,
DS_DEVICE_NAME_LENGTH, &buffer, nullptr);
length = strlen(buffer);
profile->devices[next].oclDriverVersion = (char*)malloc(length+1);
memcpy(profile->devices[next].oclDriverVersion, buffer, length+1);
profile->devices[next].oclDriverVersion = (char *)malloc(length + 1);
memcpy(profile->devices[next].oclDriverVersion, buffer, length + 1);
}
}
profile->devices[next].type = DS_DEVICE_NATIVE_CPU;
@ -247,10 +244,10 @@ cleanup:
return status;
}
static ds_status profileDevices(ds_profile* profile,
static ds_status profileDevices(ds_profile *profile,
const ds_evaluation_type type,
ds_perf_evaluator evaluator,
void* evaluatorData, unsigned int* numUpdates) {
void *evaluatorData, unsigned int *numUpdates) {
ds_status status = DS_SUCCESS;
unsigned int i;
unsigned int updates = 0;
@ -266,37 +263,37 @@ static ds_status profileDevices(ds_profile* profile,
ds_status evaluatorStatus;
switch (type) {
case DS_EVALUATE_NEW_ONLY:
if (profile->devices[i].score != nullptr) break;
case DS_EVALUATE_NEW_ONLY:
if (profile->devices[i].score != nullptr) break;
// else fall through
case DS_EVALUATE_ALL:
evaluatorStatus = evaluator(profile->devices+i, evaluatorData);
if (evaluatorStatus != DS_SUCCESS) {
status = evaluatorStatus;
return status;
}
updates++;
break;
default:
return DS_INVALID_PERF_EVALUATOR_TYPE;
break;
case DS_EVALUATE_ALL:
evaluatorStatus = evaluator(profile->devices + i, evaluatorData);
if (evaluatorStatus != DS_SUCCESS) {
status = evaluatorStatus;
return status;
}
updates++;
break;
default:
return DS_INVALID_PERF_EVALUATOR_TYPE;
break;
};
}
if (numUpdates)
*numUpdates = updates;
if (numUpdates) *numUpdates = updates;
return status;
}
static const char* findString(const char* contentStart, const char* contentEnd,
const char* string) {
static const char *findString(const char *contentStart, const char *contentEnd,
const char *string) {
size_t stringLength;
const char* currentPosition;
const char* found = nullptr;
const char *currentPosition;
const char *found = nullptr;
stringLength = strlen(string);
currentPosition = contentStart;
for(currentPosition = contentStart; currentPosition < contentEnd; currentPosition++) {
for (currentPosition = contentStart; currentPosition < contentEnd;
currentPosition++) {
if (*currentPosition == string[0]) {
if (currentPosition+stringLength < contentEnd) {
if (currentPosition + stringLength < contentEnd) {
if (strncmp(currentPosition, string, stringLength) == 0) {
found = currentPosition;
break;
@ -307,14 +304,14 @@ static const char* findString(const char* contentStart, const char* contentEnd,
return found;
}
static ds_status readProFile(const char* fileName, char** content,
size_t* contentSize) {
static ds_status readProFile(const char *fileName, char **content,
size_t *contentSize) {
size_t size = 0;
*contentSize = 0;
*content = nullptr;
FILE* input = fopen(fileName, "rb");
FILE *input = fopen(fileName, "rb");
if (input == nullptr) {
return DS_FILE_ERROR;
}
@ -322,7 +319,7 @@ static ds_status readProFile(const char* fileName, char** content,
fseek(input, 0L, SEEK_END);
size = ftell(input);
rewind(input);
char* binary = (char*)malloc(size);
char *binary = (char *)malloc(size);
if (binary == nullptr) {
fclose(input);
return DS_FILE_ERROR;
@ -335,26 +332,25 @@ static ds_status readProFile(const char* fileName, char** content,
return DS_SUCCESS;
}
typedef ds_status (*ds_score_deserializer)(ds_device* device,
const unsigned char* serializedScore,
typedef ds_status (*ds_score_deserializer)(ds_device *device,
const unsigned char *serializedScore,
unsigned int serializedScoreSize);
static ds_status readProfileFromFile(ds_profile* profile,
static ds_status readProfileFromFile(ds_profile *profile,
ds_score_deserializer deserializer,
const char* file) {
const char *file) {
ds_status status = DS_SUCCESS;
char* contentStart = nullptr;
const char* contentEnd = nullptr;
char *contentStart = nullptr;
const char *contentEnd = nullptr;
size_t contentSize;
if (profile == nullptr) return DS_INVALID_PROFILE;
status = readProFile(file, &contentStart, &contentSize);
if (status == DS_SUCCESS) {
const char* currentPosition;
const char* dataStart;
const char* dataEnd;
const char *currentPosition;
const char *dataStart;
const char *dataEnd;
size_t versionStringLength;
contentEnd = contentStart + contentSize;
@ -375,37 +371,37 @@ static ds_status readProfileFromFile(ds_profile* profile,
}
versionStringLength = strlen(profile->version);
if (versionStringLength!=(dataEnd-dataStart)
|| strncmp(profile->version, dataStart, versionStringLength)!=0) {
if (versionStringLength != (dataEnd - dataStart) ||
strncmp(profile->version, dataStart, versionStringLength) != 0) {
// version mismatch
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
currentPosition = dataEnd+strlen(DS_TAG_VERSION_END);
currentPosition = dataEnd + strlen(DS_TAG_VERSION_END);
// parse the device information
while (1) {
unsigned int i;
const char* deviceTypeStart;
const char* deviceTypeEnd;
const char *deviceTypeStart;
const char *deviceTypeEnd;
ds_device_type deviceType;
const char* deviceNameStart;
const char* deviceNameEnd;
const char *deviceNameStart;
const char *deviceNameEnd;
const char* deviceScoreStart;
const char* deviceScoreEnd;
const char *deviceScoreStart;
const char *deviceScoreEnd;
const char* deviceDriverStart;
const char* deviceDriverEnd;
const char *deviceDriverStart;
const char *deviceDriverEnd;
dataStart = findString(currentPosition, contentEnd, DS_TAG_DEVICE);
if (dataStart == nullptr) {
// nothing useful remain, quit...
break;
}
dataStart+=strlen(DS_TAG_DEVICE);
dataStart += strlen(DS_TAG_DEVICE);
dataEnd = findString(dataStart, contentEnd, DS_TAG_DEVICE_END);
if (dataEnd == nullptr) {
status = DS_PROFILE_FILE_ERROR;
@ -418,9 +414,9 @@ static ds_status readProfileFromFile(ds_profile* profile,
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
deviceTypeStart+=strlen(DS_TAG_DEVICE_TYPE);
deviceTypeEnd = findString(deviceTypeStart, contentEnd,
DS_TAG_DEVICE_TYPE_END);
deviceTypeStart += strlen(DS_TAG_DEVICE_TYPE);
deviceTypeEnd =
findString(deviceTypeStart, contentEnd, DS_TAG_DEVICE_TYPE_END);
if (deviceTypeEnd == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
@ -429,27 +425,26 @@ static ds_status readProfileFromFile(ds_profile* profile,
// parse the device name
if (deviceType == DS_DEVICE_OPENCL_DEVICE) {
deviceNameStart = findString(dataStart, contentEnd, DS_TAG_DEVICE_NAME);
if (deviceNameStart == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
deviceNameStart+=strlen(DS_TAG_DEVICE_NAME);
deviceNameEnd = findString(deviceNameStart, contentEnd,
DS_TAG_DEVICE_NAME_END);
deviceNameStart += strlen(DS_TAG_DEVICE_NAME);
deviceNameEnd =
findString(deviceNameStart, contentEnd, DS_TAG_DEVICE_NAME_END);
if (deviceNameEnd == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
deviceDriverStart = findString(dataStart, contentEnd,
DS_TAG_DEVICE_DRIVER_VERSION);
deviceDriverStart =
findString(dataStart, contentEnd, DS_TAG_DEVICE_DRIVER_VERSION);
if (deviceDriverStart == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
deviceDriverStart+=strlen(DS_TAG_DEVICE_DRIVER_VERSION);
deviceDriverStart += strlen(DS_TAG_DEVICE_DRIVER_VERSION);
deviceDriverEnd = findString(deviceDriverStart, contentEnd,
DS_TAG_DEVICE_DRIVER_VERSION_END);
if (deviceDriverEnd == nullptr) {
@ -465,23 +460,24 @@ static ds_status readProfileFromFile(ds_profile* profile,
actualDeviceNameLength = strlen(profile->devices[i].oclDeviceName);
driverVersionLength = strlen(profile->devices[i].oclDriverVersion);
if (actualDeviceNameLength == (deviceNameEnd - deviceNameStart)
&& driverVersionLength == (deviceDriverEnd - deviceDriverStart)
&& strncmp(profile->devices[i].oclDeviceName, deviceNameStart,
actualDeviceNameLength)==0
&& strncmp(profile->devices[i].oclDriverVersion, deviceDriverStart,
driverVersionLength)==0) {
deviceScoreStart = findString(dataStart, contentEnd, DS_TAG_SCORE);
if (actualDeviceNameLength == (deviceNameEnd - deviceNameStart) &&
driverVersionLength == (deviceDriverEnd - deviceDriverStart) &&
strncmp(profile->devices[i].oclDeviceName, deviceNameStart,
actualDeviceNameLength) == 0 &&
strncmp(profile->devices[i].oclDriverVersion, deviceDriverStart,
driverVersionLength) == 0) {
deviceScoreStart =
findString(dataStart, contentEnd, DS_TAG_SCORE);
if (deviceNameStart == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
deviceScoreStart+=strlen(DS_TAG_SCORE);
deviceScoreEnd = findString(deviceScoreStart, contentEnd,
DS_TAG_SCORE_END);
status = deserializer(profile->devices+i,
(const unsigned char*)deviceScoreStart,
deviceScoreEnd-deviceScoreStart);
deviceScoreStart += strlen(DS_TAG_SCORE);
deviceScoreEnd =
findString(deviceScoreStart, contentEnd, DS_TAG_SCORE_END);
status = deserializer(profile->devices + i,
(const unsigned char *)deviceScoreStart,
deviceScoreEnd - deviceScoreStart);
if (status != DS_SUCCESS) {
goto cleanup;
}
@ -496,12 +492,12 @@ static ds_status readProfileFromFile(ds_profile* profile,
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
deviceScoreStart+=strlen(DS_TAG_SCORE);
deviceScoreEnd = findString(deviceScoreStart, contentEnd,
DS_TAG_SCORE_END);
status = deserializer(profile->devices+i,
(const unsigned char*)deviceScoreStart,
deviceScoreEnd-deviceScoreStart);
deviceScoreStart += strlen(DS_TAG_SCORE);
deviceScoreEnd =
findString(deviceScoreStart, contentEnd, DS_TAG_SCORE_END);
status = deserializer(profile->devices + i,
(const unsigned char *)deviceScoreStart,
deviceScoreEnd - deviceScoreStart);
if (status != DS_SUCCESS) {
goto cleanup;
}
@ -510,7 +506,7 @@ static ds_status readProfileFromFile(ds_profile* profile,
}
// skip over the current one to find the next device
currentPosition = dataEnd+strlen(DS_TAG_DEVICE_END);
currentPosition = dataEnd + strlen(DS_TAG_DEVICE_END);
}
}
cleanup:
@ -518,17 +514,17 @@ cleanup:
return status;
}
typedef ds_status (*ds_score_serializer)(ds_device* device,
void** serializedScore,
unsigned int* serializedScoreSize);
static ds_status writeProfileToFile(ds_profile* profile,
typedef ds_status (*ds_score_serializer)(ds_device *device,
void **serializedScore,
unsigned int *serializedScoreSize);
static ds_status writeProfileToFile(ds_profile *profile,
ds_score_serializer serializer,
const char* file) {
const char *file) {
ds_status status = DS_SUCCESS;
if (profile == nullptr) return DS_INVALID_PROFILE;
FILE* profileFile = fopen(file, "wb");
FILE *profileFile = fopen(file, "wb");
if (profileFile == nullptr) {
status = DS_FILE_ERROR;
} else {
@ -536,25 +532,26 @@ static ds_status writeProfileToFile(ds_profile* profile,
// write version string
fwrite(DS_TAG_VERSION, sizeof(char), strlen(DS_TAG_VERSION), profileFile);
fwrite(profile->version, sizeof(char), strlen(profile->version), profileFile);
fwrite(DS_TAG_VERSION_END, sizeof(char), strlen(DS_TAG_VERSION_END), profileFile);
fwrite(profile->version, sizeof(char), strlen(profile->version),
profileFile);
fwrite(DS_TAG_VERSION_END, sizeof(char), strlen(DS_TAG_VERSION_END),
profileFile);
fwrite("\n", sizeof(char), 1, profileFile);
for (i = 0; i < profile->numDevices && status == DS_SUCCESS; i++) {
void* serializedScore;
void *serializedScore;
unsigned int serializedScoreSize;
fwrite(DS_TAG_DEVICE, sizeof(char), strlen(DS_TAG_DEVICE), profileFile);
fwrite(DS_TAG_DEVICE_TYPE, sizeof(char), strlen(DS_TAG_DEVICE_TYPE),
profileFile);
fwrite(&profile->devices[i].type,sizeof(ds_device_type),1, profileFile);
fwrite(&profile->devices[i].type, sizeof(ds_device_type), 1, profileFile);
fwrite(DS_TAG_DEVICE_TYPE_END, sizeof(char),
strlen(DS_TAG_DEVICE_TYPE_END), profileFile);
switch(profile->devices[i].type) {
case DS_DEVICE_NATIVE_CPU:
{
switch (profile->devices[i].type) {
case DS_DEVICE_NATIVE_CPU: {
// There's no need to emit a device name for the native CPU device.
/*
fwrite(DS_TAG_DEVICE_NAME, sizeof(char), strlen(DS_TAG_DEVICE_NAME),
@ -564,14 +561,12 @@ static ds_status writeProfileToFile(ds_profile* profile,
fwrite(DS_TAG_DEVICE_NAME_END, sizeof(char),
strlen(DS_TAG_DEVICE_NAME_END), profileFile);
*/
}
break;
case DS_DEVICE_OPENCL_DEVICE:
{
} break;
case DS_DEVICE_OPENCL_DEVICE: {
fwrite(DS_TAG_DEVICE_NAME, sizeof(char), strlen(DS_TAG_DEVICE_NAME),
profileFile);
fwrite(profile->devices[i].oclDeviceName,
sizeof(char),strlen(profile->devices[i].oclDeviceName), profileFile);
fwrite(profile->devices[i].oclDeviceName, sizeof(char),
strlen(profile->devices[i].oclDeviceName), profileFile);
fwrite(DS_TAG_DEVICE_NAME_END, sizeof(char),
strlen(DS_TAG_DEVICE_NAME_END), profileFile);
@ -581,24 +576,25 @@ static ds_status writeProfileToFile(ds_profile* profile,
strlen(profile->devices[i].oclDriverVersion), profileFile);
fwrite(DS_TAG_DEVICE_DRIVER_VERSION_END, sizeof(char),
strlen(DS_TAG_DEVICE_DRIVER_VERSION_END), profileFile);
}
break;
default:
status = DS_UNKNOWN_DEVICE_TYPE;
break;
} break;
default:
status = DS_UNKNOWN_DEVICE_TYPE;
break;
};
fwrite(DS_TAG_SCORE, sizeof(char), strlen(DS_TAG_SCORE), profileFile);
status = serializer(profile->devices+i, &serializedScore,
status = serializer(profile->devices + i, &serializedScore,
&serializedScoreSize);
if (status == DS_SUCCESS && serializedScore != nullptr &&
serializedScoreSize > 0) {
fwrite(serializedScore, sizeof(char), serializedScoreSize, profileFile);
free(serializedScore);
}
fwrite(DS_TAG_SCORE_END, sizeof(char), strlen(DS_TAG_SCORE_END), profileFile);
fwrite(DS_TAG_DEVICE_END, sizeof(char), strlen(DS_TAG_DEVICE_END), profileFile);
fwrite("\n",sizeof(char),1,profileFile);
fwrite(DS_TAG_SCORE_END, sizeof(char), strlen(DS_TAG_SCORE_END),
profileFile);
fwrite(DS_TAG_DEVICE_END, sizeof(char), strlen(DS_TAG_DEVICE_END),
profileFile);
fwrite("\n", sizeof(char), 1, profileFile);
}
fclose(profileFile);
}

View File

@ -65,8 +65,7 @@ const int kMinRampSize = 1000;
// corresponding to darkening on the copier and <0 lighter and 0 not copied.
// Exposures in [-2,2] are most useful, with -3 and 3 being extreme.
// If rotation is nullptr, rotation is skipped. If *rotation is non-zero, the
// pix
// is rotated by *rotation else it is randomly rotated and *rotation is
// pix is rotated by *rotation else it is randomly rotated and *rotation is
// modified.
//
// HOW IT WORKS:

View File

@ -84,17 +84,16 @@ void SVMutex::Unlock() {
}
// Create new thread.
void SVSync::StartThread(void *(*func)(void*), void* arg) {
void SVSync::StartThread(void* (*func)(void*), void* arg) {
#ifdef _WIN32
LPTHREAD_START_ROUTINE f = (LPTHREAD_START_ROUTINE) func;
LPTHREAD_START_ROUTINE f = (LPTHREAD_START_ROUTINE)func;
DWORD threadid;
HANDLE newthread = CreateThread(
NULL, // default security attributes
0, // use default stack size
f, // thread function
arg, // argument to thread function
0, // use default creation flags
&threadid); // returns the thread identifier
HANDLE newthread = CreateThread(NULL, // default security attributes
0, // use default stack size
f, // thread function
arg, // argument to thread function
0, // use default creation flags
&threadid); // returns the thread identifier
#else
pthread_t helper;
pthread_attr_t attr;