-
Notifications
You must be signed in to change notification settings - Fork 772
fix: build and run on windows with MinGW #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tangxinfa
wants to merge
1
commit into
HardySimpson:master
Choose a base branch
from
tangxinfa:fix-mingw-build
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,16 +62,12 @@ static int zlog_spec_write_time_internal(zlog_spec_t * a_spec, zlog_thread_t * a | |
| time_t now_sec = a_thread->event->time_stamp.tv_sec; | ||
| struct tm *time; | ||
| time_t *time_sec; | ||
| typedef struct tm *(*zlog_spec_time_fn) (const time_t*, struct tm *); | ||
| zlog_spec_time_fn time_stamp_convert_function; | ||
| if( use_utc ) { | ||
| time = &(a_thread->event->time_utc); | ||
| time_sec = &(a_thread->event->time_utc_sec); | ||
| time_stamp_convert_function = gmtime_r; | ||
| } else { | ||
| time = &(a_thread->event->time_local); | ||
| time_sec = &(a_thread->event->time_local_sec); | ||
| time_stamp_convert_function = localtime_r; | ||
| } | ||
|
|
||
| /* the event meet the 1st time_spec in his life cycle */ | ||
|
|
@@ -82,7 +78,11 @@ static int zlog_spec_write_time_internal(zlog_spec_t * a_spec, zlog_thread_t * a | |
|
|
||
| /* When this event's last cached time_local is not now */ | ||
| if (*time_sec != now_sec) { | ||
| time_stamp_convert_function(&(now_sec), time); | ||
| if (use_utc) { | ||
| gmtime_r(&(now_sec), time); | ||
| } else { | ||
| localtime_r(&(now_sec), time); | ||
| } | ||
| *time_sec = now_sec; | ||
| } | ||
|
|
||
|
|
@@ -241,7 +241,7 @@ static int zlog_spec_write_pid(zlog_spec_t * a_spec, zlog_thread_t * a_thread, z | |
| if (a_thread->event->pid != a_thread->event->last_pid) { | ||
| a_thread->event->last_pid = a_thread->event->pid; | ||
| a_thread->event->pid_str_len | ||
| = sprintf(a_thread->event->pid_str, "%u", a_thread->event->pid); | ||
| = sprintf(a_thread->event->pid_str, "%ld", (long)a_thread->event->pid); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Causes segmentation fault |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -264,13 +264,15 @@ static int zlog_spec_write_tid_long(zlog_spec_t * a_spec, zlog_thread_t * a_thre | |
| return zlog_buf_append(a_buf, a_thread->event->tid_str, a_thread->event->tid_str_len); | ||
| } | ||
|
|
||
| #if defined __linux__ || __APPLE__ | ||
| static int zlog_spec_write_ktid(zlog_spec_t * a_spec, zlog_thread_t * a_thread, zlog_buf_t * a_buf) | ||
| { | ||
|
|
||
| /* don't need to get ktid again, as tmap_new_thread fetched it already */ | ||
| /* and fork not change tid */ | ||
| return zlog_buf_append(a_buf, a_thread->event->ktid_str, a_thread->event->ktid_str_len); | ||
| } | ||
| #endif | ||
|
|
||
| static int zlog_spec_write_level_lowercase(zlog_spec_t * a_spec, zlog_thread_t * a_thread, zlog_buf_t * a_buf) | ||
| { | ||
|
|
@@ -647,9 +649,11 @@ zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_next, int *time_c | |
| case 'H': | ||
| a_spec->write_buf = zlog_spec_write_hostname; | ||
| break; | ||
| #if defined __linux__ || __APPLE__ | ||
| case 'k': | ||
| a_spec->write_buf = zlog_spec_write_ktid; | ||
| break; | ||
| #endif | ||
| case 'L': | ||
| a_spec->write_buf = zlog_spec_write_srcline; | ||
| break; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,7 @@ | |
| #if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6) | ||
| #define zlog_fstat fstat64 | ||
| #define zlog_stat stat64 | ||
| #elif defined(_WIN32) | ||
| #elif defined(_WIN32) && !defined(__MINGW32__) | ||
| #define zlog_fstat _fstat | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Conflict with MinGW defined macros |
||
| #define zlog_stat _stat | ||
| #else | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On MinGW gmtime_r and localtime_r are inline functions, can't get function pointers