mirror of https://github.com/BOINC/boinc.git
printf-free signal handler in API
svn path=/trunk/boinc/; revision=6991
This commit is contained in:
parent
2281a83b45
commit
11b10cb0a3
|
@ -179,7 +179,7 @@ static int boinc_worker_thread_cpu_time(double& cpu) {
|
|||
// Apparently sprintf() isn't safe to use in a signal handler.
|
||||
// So roll our own.
|
||||
//
|
||||
void itoa(int x, char* &p) {
|
||||
static void itoa(int x, char* &p) {
|
||||
if (x<0) {
|
||||
x = -x;
|
||||
*p++ = '-';
|
||||
|
@ -195,8 +195,13 @@ void itoa(int x, char* &p) {
|
|||
|
||||
}
|
||||
|
||||
void dtoa(double x, char* p) {
|
||||
static void dtoa(double x, char* p) {
|
||||
int exp = 0;
|
||||
if (x == 0) {
|
||||
*p++ = '0';
|
||||
*p = 0;
|
||||
return;
|
||||
}
|
||||
if (x < 0) {
|
||||
x = -x;
|
||||
*p++ = '-';
|
||||
|
@ -219,14 +224,17 @@ void dtoa(double x, char* p) {
|
|||
}
|
||||
}
|
||||
|
||||
void append(const char* from, char* &to) {
|
||||
static void append(const char* from, char* &to) {
|
||||
while (*from) {
|
||||
*to++ = *from++;
|
||||
}
|
||||
}
|
||||
|
||||
void tag_double(const char* tag, double x, char* p) {
|
||||
#if 0
|
||||
FILE* fdbg = 0;
|
||||
static void tag_double(const char* tag, double x, char* p) {
|
||||
#if 1
|
||||
fprintf(fdbg, "tag_double: %s %f\n", tag, x); fflush(fdbg);
|
||||
|
||||
char buf[256];
|
||||
append("<", p);
|
||||
append(tag, p);
|
||||
|
@ -237,6 +245,7 @@ void tag_double(const char* tag, double x, char* p) {
|
|||
append(tag, p);
|
||||
append(">\n", p);
|
||||
*p = 0;
|
||||
fprintf(fdbg, "tag_double end: %s %f\n", tag, x); fflush(fdbg);
|
||||
#else
|
||||
sprintf(p, "<%s>%f</%s>\n", tag, x, tag);
|
||||
#endif
|
||||
|
@ -252,9 +261,15 @@ static bool update_app_progress(
|
|||
|
||||
if (standalone) return true;
|
||||
|
||||
if (!fdbg) fdbg = fopen("apidbg.txt", "w");
|
||||
fprintf(fdbg, "starting %f %f\n",cpu_t, cp_cpu_t); fflush(fdbg);
|
||||
|
||||
tag_double("current_cpu_time", cpu_t, buf);
|
||||
fprintf(fdbg, "buf1: %s\n", buf); fflush(fdbg);
|
||||
|
||||
strcpy(msg_buf, buf);
|
||||
tag_double("checkpoint_cpu_time", cp_cpu_t, buf);
|
||||
fprintf(fdbg, "buf2: %s\n", buf); fflush(fdbg);
|
||||
strcat(msg_buf, buf);
|
||||
if (fraction_done >= 0) {
|
||||
double range = aid.fraction_done_end - aid.fraction_done_start;
|
||||
|
@ -278,6 +293,8 @@ static bool update_app_progress(
|
|||
tag_double("fpops_cumulative", fpops_cumulative, buf);
|
||||
strcat(msg_buf, buf);
|
||||
}
|
||||
fprintf(fdbg, "msg: %s\n", msg_buf); fflush(fdbg);
|
||||
|
||||
return app_client_shm->shm->app_status.send_msg(msg_buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ int do_checkpoint(MFILE& mf, int nchars) {
|
|||
}
|
||||
|
||||
static void use_some_cpu() {
|
||||
#if 0
|
||||
#if 1
|
||||
double j = 3.14159;
|
||||
int i, n = 0;
|
||||
for (i=0; i<20000000; i++) {
|
||||
|
@ -155,7 +155,7 @@ int main(int argc, char **argv) {
|
|||
for (i=0; i<argc; i++) {
|
||||
fprintf(stderr, "APP: upper_case: argv[%d] is %s\n", i, argv[i]);
|
||||
if (!strcmp(argv[i], "-run_slow")) run_slow = true;
|
||||
if (!strcmp(argv[i], "-cpu_time")) cpu_time = 1;
|
||||
if (!strcmp(argv[i], "-cpu_time")) cpu_time = true;
|
||||
if (!strcmp(argv[i], "-signal")) raise_signal = true;
|
||||
if (!strcmp(argv[i], "-exit")) random_exit = true;
|
||||
}
|
||||
|
|
|
@ -9837,3 +9837,16 @@ Rom 2 Aug 2005
|
|||
BOINCGUIApp.cpp, .h
|
||||
stdwx.h
|
||||
ViewMessages.cpp, .h
|
||||
|
||||
David 2 Aug 2005
|
||||
- Fix new API stuff that avoids using printf in signal handler.
|
||||
(my scaling of double to put them in the range [.1,1)
|
||||
failed to take into account zero... arrgh!)
|
||||
|
||||
api/
|
||||
boinc_api.C
|
||||
apps/
|
||||
upper_case.C
|
||||
win_build/
|
||||
boinc_gui.vcproj
|
||||
upper_case.vcproj
|
||||
|
|
|
@ -22,7 +22,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "upper_case", "upper_case.vc
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boinc_gui", "boinc_gui.vcproj", "{78BA7B4E-4E37-4CAB-B954-CD906AC0E011}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{21E7357D-41D8-444C-A120-18064B497174} = {21E7357D-41D8-444C-A120-18064B497174}
|
||||
{E8F6BD7E-461A-4733-B7D8-37B09A099ED8} = {E8F6BD7E-461A-4733-B7D8-37B09A099ED8}
|
||||
{0B6B4994-5C4B-49F3-B717-17603AFB789E} = {0B6B4994-5C4B-49F3-B717-17603AFB789E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../;../lib/;../api/;../RSAEuro/source/;../client/win/;../client"
|
||||
AdditionalIncludeDirectories="../;../openssl/include/;../lib/;../api/;../RSAEuro/source/;../client/win/;../client"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
|
@ -119,10 +119,11 @@
|
|||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="libeay32.lib"
|
||||
OutputFile=".\Build\Debug/boinc_gui.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories="..\boinc_dll\Debug"
|
||||
AdditionalLibraryDirectories="../openssl/win32/x86/lib;..\boinc_dll\Debug"
|
||||
IgnoreAllDefaultLibraries="FALSE"
|
||||
IgnoreDefaultLibraryNames=""
|
||||
DelayLoadDLLs="oleacc.dll"
|
||||
|
@ -580,6 +581,9 @@
|
|||
<File
|
||||
RelativePath="..\client\gui_rpc_server.C">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\client\gui_rpc_server_ops.C">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\client\gui_titles.C">
|
||||
<FileConfiguration
|
||||
|
@ -1305,10 +1309,10 @@
|
|||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
||||
<File
|
||||
RelativePath="..\client\win\boinc.bmp">
|
||||
RelativePath="..\client\win\res\boinc.bmp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\client\win\res\boinc.bmp">
|
||||
RelativePath="..\client\win\boinc.bmp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\client\win\boinc_gui.rc">
|
||||
|
@ -1328,10 +1332,10 @@
|
|||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\client\win\res\boincsm.bmp">
|
||||
RelativePath="..\client\win\boincsm.bmp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\client\win\boincsm.bmp">
|
||||
RelativePath="..\client\win\res\boincsm.bmp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\res\CoreClient.ico">
|
||||
|
|
|
@ -116,13 +116,13 @@
|
|||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="MSVCRTD.LIB MSVCPRTD.LIB kernel32.lib user32.lib gdi32.lib winmm.lib opengl32.lib glu32.lib glaux.lib ole32.lib"
|
||||
OutputFile=".\Build\Debug/uppercase_2.06_windows_intelx86.exe"
|
||||
OutputFile=".\Build\Debug/uppercase_4.04_windows_intelx86.exe"
|
||||
LinkIncremental="0"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories="..\boinc_dll\Debug"
|
||||
IgnoreAllDefaultLibraries="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Build\Debug/uppercase_2.06_windows_intelx86.pdb"
|
||||
ProgramDatabaseFile=".\Build\Debug/uppercase_4.04_windows_intelx86.pdb"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
|
|
Loading…
Reference in New Issue