Skip to content

Commit

Permalink
Remove HD macros for C time functions (#4337)
Browse files Browse the repository at this point in the history
* HDasctime
* HDclock
* HDctime
* HDdifftime
* HDgmtime
* HDlocaltime
* HDmktime
* HDtime
* HDtzset

HDgettimeofday will be done later
  • Loading branch information
derobins authored Apr 7, 2024
1 parent a6d689a commit 0de523b
Show file tree
Hide file tree
Showing 44 changed files with 108 additions and 139 deletions.
44 changes: 22 additions & 22 deletions src/H5Clog_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ H5C__json_write_start_log_msg(void *udata)
\"action\":\"logging start\"\
},\n\
",
(long long)HDtime(NULL));
(long long)time(NULL));

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -378,7 +378,7 @@ H5C__json_write_stop_log_msg(void *udata)
}\n\
]}\n\
",
(long long)HDtime(NULL));
(long long)time(NULL));

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -417,7 +417,7 @@ H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value)
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (int)fxn_ret_value);
(long long)time(NULL), (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -455,7 +455,7 @@ H5C__json_write_destroy_cache_log_msg(void *udata)
\"action\":\"destroy\"\
},\n\
",
(long long)HDtime(NULL));
(long long)time(NULL));

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -494,7 +494,7 @@ H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value)
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (int)fxn_ret_value);
(long long)time(NULL), (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -535,7 +535,7 @@ H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id,
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)address, (int)type_id, (int)fxn_ret_value);
(long long)time(NULL), (unsigned long)address, (int)type_id, (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -574,7 +574,7 @@ H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value)
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (int)fxn_ret_value);
(long long)time(NULL), (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -618,7 +618,7 @@ H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id,
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)address, type_id, flags, (int)size, (int)fxn_ret_value);
(long long)time(NULL), (unsigned long)address, type_id, flags, (int)size, (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -659,7 +659,7 @@ H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *e
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
(long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -700,7 +700,7 @@ H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *e
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
(long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -742,7 +742,7 @@ H5C__json_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_ent
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
(long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -784,7 +784,7 @@ H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
(long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -827,7 +827,7 @@ H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_ad
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)old_addr, (unsigned long)new_addr, type_id,
(long long)time(NULL), (unsigned long)old_addr, (unsigned long)new_addr, type_id,
(int)fxn_ret_value);

/* Write the log message to the file */
Expand Down Expand Up @@ -869,7 +869,7 @@ H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, h
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
(long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -914,7 +914,7 @@ H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent,
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)parent->addr, (unsigned long)child->addr,
(long long)time(NULL), (unsigned long)parent->addr, (unsigned long)child->addr,
(int)fxn_ret_value);

/* Write the log message to the file */
Expand Down Expand Up @@ -966,7 +966,7 @@ H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entr
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)entry->addr, type_id, rw_s, (int)entry->size,
(long long)time(NULL), (unsigned long)entry->addr, type_id, rw_s, (int)entry->size,
(int)fxn_ret_value);

/* Write the log message to the file */
Expand Down Expand Up @@ -1010,7 +1010,7 @@ H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)entry->addr, (int)new_size, (int)fxn_ret_value);
(long long)time(NULL), (unsigned long)entry->addr, (int)new_size, (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -1051,7 +1051,7 @@ H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
(long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -1096,7 +1096,7 @@ H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent,
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)parent->addr, (unsigned long)child->addr,
(long long)time(NULL), (unsigned long)parent->addr, (unsigned long)child->addr,
(int)fxn_ret_value);

/* Write the log message to the file */
Expand Down Expand Up @@ -1140,7 +1140,7 @@ H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_i
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)address, type_id, flags, (int)fxn_ret_value);
(long long)time(NULL), (unsigned long)address, type_id, flags, (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -1181,7 +1181,7 @@ H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (int)fxn_ret_value);
(long long)time(NULL), (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down Expand Up @@ -1222,7 +1222,7 @@ H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry
\"returned\":%d\
},\n\
",
(long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
(long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);

/* Write the log message to the file */
if (H5C__json_write_log_message(json_udata) < 0)
Expand Down
4 changes: 2 additions & 2 deletions src/H5Dmpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1184,8 +1184,8 @@ H5D__piece_io(H5D_io_info_t *io_info)
HGOTO_ERROR(H5E_IO, H5E_OPENERROR, FAIL, "couldn't open debugging log file");

/* Print a short header for this I/O operation */
time_now = HDtime(NULL);
fprintf(debug_log_file, "##### %s", HDasctime(HDlocaltime(&time_now)));
time_now = time(NULL);
fprintf(debug_log_file, "##### %s", asctime(localtime(&time_now)));

debug_stream = debug_log_file;
}
Expand Down
8 changes: 4 additions & 4 deletions src/H5FDcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,15 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size)

if (-1 == bytes_wrote) { /* error */
int myerrno = errno;
time_t mytime = HDtime(NULL);
time_t mytime = time(NULL);

offset = HDlseek(file->fd, 0, SEEK_CUR);

HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
"write to backing store failed: time = %s, filename = '%s', file descriptor = %d, "
"errno = %d, error message = '%s', ptr = %p, total write size = %llu, bytes this "
"sub-write = %llu, bytes actually written = %llu, offset = %llu",
HDctime(&mytime), file->name, file->fd, myerrno, strerror(myerrno), (void *)ptr,
ctime(&mytime), file->name, file->fd, myerrno, strerror(myerrno), (void *)ptr,
(unsigned long long)size, (unsigned long long)bytes_in,
(unsigned long long)bytes_wrote, (unsigned long long)offset);
} /* end if */
Expand Down Expand Up @@ -900,7 +900,7 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr

if (-1 == bytes_read) { /* error */
int myerrno = errno;
time_t mytime = HDtime(NULL);
time_t mytime = time(NULL);

offset = HDlseek(file->fd, 0, SEEK_CUR);

Expand All @@ -909,7 +909,7 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr
"file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, "
"error message = '%s', file->mem = %p, total read size = %llu, bytes this "
"sub-read = %llu, bytes actually read = %llu, offset = %llu",
HDctime(&mytime), file->name, file->fd, myerrno, strerror(myerrno),
ctime(&mytime), file->name, file->fd, myerrno, strerror(myerrno),
(void *)file->mem, (unsigned long long)size, (unsigned long long)bytes_in,
(unsigned long long)bytes_read, (unsigned long long)offset);
} /* end if */
Expand Down
8 changes: 4 additions & 4 deletions src/H5FDlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had

if (-1 == bytes_read) { /* error */
int myerrno = errno;
time_t mytime = HDtime(NULL);
time_t mytime = time(NULL);

offset = HDlseek(file->fd, 0, SEEK_CUR);

Expand All @@ -1240,7 +1240,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had
"file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, "
"error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, "
"bytes actually read = %llu, offset = %llu",
HDctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf,
ctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf,
(unsigned long long)size, (unsigned long long)bytes_in,
(unsigned long long)bytes_read, (unsigned long long)offset);
}
Expand Down Expand Up @@ -1447,7 +1447,7 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha

if (-1 == bytes_wrote) { /* error */
int myerrno = errno;
time_t mytime = HDtime(NULL);
time_t mytime = time(NULL);

offset = HDlseek(file->fd, 0, SEEK_CUR);

Expand All @@ -1459,7 +1459,7 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha
"file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, "
"error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = "
"%llu, bytes actually written = %llu, offset = %llu",
HDctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf,
ctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf,
(unsigned long long)size, (unsigned long long)bytes_in,
(unsigned long long)bytes_wrote, (unsigned long long)offset);
} /* end if */
Expand Down
4 changes: 2 additions & 2 deletions src/H5FDonion.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,8 @@ H5FD__onion_commit_new_revision_record(H5FD_onion_t *file)

FUNC_ENTER_PACKAGE

HDtime(&rawtime);
info = HDgmtime(&rawtime);
time(&rawtime);
info = gmtime(&rawtime);
strftime(rec->time_of_creation, sizeof(rec->time_of_creation), "%Y%m%dT%H%M%SZ", info);

rec->logical_eof = file->logical_eof;
Expand Down
4 changes: 2 additions & 2 deletions src/H5FDs3comms.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,8 +1598,8 @@ gmnow(void)
struct tm *ret_value = NULL;

/* Doctor assert, checks against error in time() */
if ((time_t)(-1) != HDtime(now_ptr))
ret_value = HDgmtime(now_ptr);
if ((time_t)(-1) != time(now_ptr))
ret_value = gmtime(now_ptr);

assert(ret_value != NULL);

Expand Down
8 changes: 4 additions & 4 deletions src/H5FDsec2.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,15 +695,15 @@ H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU

if (-1 == bytes_read) { /* error */
int myerrno = errno;
time_t mytime = HDtime(NULL);
time_t mytime = time(NULL);

offset = HDlseek(file->fd, 0, SEEK_CUR);

HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL,
"file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, "
"error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, "
"bytes actually read = %llu, offset = %llu",
HDctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf,
ctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf,
(unsigned long long)size, (unsigned long long)bytes_in,
(unsigned long long)bytes_read, (unsigned long long)offset);
} /* end if */
Expand Down Expand Up @@ -801,15 +801,15 @@ H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN

if (-1 == bytes_wrote) { /* error */
int myerrno = errno;
time_t mytime = HDtime(NULL);
time_t mytime = time(NULL);

offset = HDlseek(file->fd, 0, SEEK_CUR);

HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
"file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, "
"error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = "
"%llu, bytes actually written = %llu, offset = %llu",
HDctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf,
ctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf,
(unsigned long long)size, (unsigned long long)bytes_in,
(unsigned long long)bytes_wrote, (unsigned long long)offset);
} /* end if */
Expand Down
8 changes: 4 additions & 4 deletions src/H5Odbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,16 @@ H5O__debug_real(H5F_t *f, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int
char buf[128]; /* Buffer for formatting time info */

/* Time fields */
tm = HDlocaltime(&oh->atime);
tm = localtime(&oh->atime);
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm);
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Access Time:", buf);
tm = HDlocaltime(&oh->mtime);
tm = localtime(&oh->mtime);
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm);
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Modification Time:", buf);
tm = HDlocaltime(&oh->ctime);
tm = localtime(&oh->ctime);
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm);
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Change Time:", buf);
tm = HDlocaltime(&oh->btime);
tm = localtime(&oh->btime);
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm);
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Birth Time:", buf);
} /* end if */
Expand Down
4 changes: 2 additions & 2 deletions src/H5Omtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ H5O__mtime_encode(H5F_t H5_ATTR_UNUSED *f, bool H5_ATTR_UNUSED disable_shared, s
assert(mesg);

/* encode */
tm = HDgmtime(mesg);
tm = gmtime(mesg);
snprintf((char *)p, p_size, "%04d%02d%02d%02d%02d%02d", 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);

Expand Down Expand Up @@ -415,7 +415,7 @@ H5O__mtime_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int i
assert(fwidth >= 0);

/* debug */
tm = HDlocaltime(mesg);
tm = localtime(mesg);

strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm);
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Time:", buf);
Expand Down
Loading

0 comments on commit 0de523b

Please sign in to comment.