Skip to content

Commit

Permalink
Remove HD from last non-win32 C89 functions (HDFGroup#4348)
Browse files Browse the repository at this point in the history
Removes the HD prefix from the last C89 functions with no special
Windows equilvalent:

* rename
* rewind
* setbuf
* signal
* tmpfile
  • Loading branch information
derobins authored and qkoziol committed Apr 9, 2024
1 parent 6560397 commit a5b3a2f
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 36 deletions.
4 changes: 2 additions & 2 deletions hl/tools/h5watch/h5watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,13 +785,13 @@ main(int argc, char *argv[])
h5tools_init();

/* To exit from h5watch for SIGTERM signal */
if (HDsignal(SIGTERM, catch_signal) == SIG_ERR) {
if (signal(SIGTERM, catch_signal) == SIG_ERR) {
error_msg("An error occurred while setting a signal handler.\n");
leave(EXIT_FAILURE);
}

/* To exit from h5watch for SIGINT signal */
if (HDsignal(SIGINT, catch_signal) == SIG_ERR) {
if (signal(SIGINT, catch_signal) == SIG_ERR) {
error_msg("An error occurred while setting a signal handler.\n");
leave(EXIT_FAILURE);
}
Expand Down
2 changes: 1 addition & 1 deletion src/H5Clog_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ H5C__log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mp
/* Open log file and set it to be unbuffered */
if (NULL == (json_udata->outfile = fopen(file_name, "w")))
HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "can't create mdc log file");
HDsetbuf(json_udata->outfile, NULL);
setbuf(json_udata->outfile, NULL);

done:
if (file_name)
Expand Down
2 changes: 1 addition & 1 deletion src/H5Clog_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ H5C__log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int m
/* Open log file and set it to be unbuffered */
if (NULL == (trace_udata->outfile = fopen(file_name, "w")))
HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "can't create mdc log file");
HDsetbuf(trace_udata->outfile, NULL);
setbuf(trace_udata->outfile, NULL);

/* Write the header */
fprintf(trace_udata->outfile, "### HDF5 metadata cache trace file version 1 ###\n");
Expand Down
15 changes: 0 additions & 15 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -804,18 +804,9 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDremove
#define HDremove(S) remove(S)
#endif
#ifndef HDrename
#define HDrename(OLD, NEW) rename(OLD, NEW)
#endif
#ifndef HDrewind
#define HDrewind(F) rewind(F)
#endif
#ifndef HDrmdir
#define HDrmdir(S) rmdir(S)
#endif
#ifndef HDsetbuf
#define HDsetbuf(F, S) setbuf(F, S)
#endif
#ifndef HDsetenv
#define HDsetenv(N, V, O) setenv(N, V, O)
#endif
Expand All @@ -831,9 +822,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDsigemptyset
#define HDsigemptyset(S) sigemptyset(S)
#endif
#ifndef HDsignal
#define HDsignal(N, F) signal(N, F)
#endif
#ifndef HDsleep
#define HDsleep(N) sleep(N)
#endif
Expand All @@ -856,9 +844,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDstrtok_r
#define HDstrtok_r(X, Y, Z) strtok_r(X, Y, Z)
#endif
#ifndef HDtmpfile
#define HDtmpfile() tmpfile()
#endif
#ifndef HDunlink
#define HDunlink(S) unlink(S)
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/app_ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ main(void)

RAND_INC(T_ESTACK);

HDsignal(SIGABRT, &Abrt_Handler);
signal(SIGABRT, &Abrt_Handler);

if (H5close() < 0)
TEST_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion test/del_many_dense_attrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ main(void)
h5_reset();

/* To exit from the file for SIGABRT signal */
if (HDsignal(SIGABRT, catch_signal) == SIG_ERR)
if (signal(SIGABRT, catch_signal) == SIG_ERR)
TEST_ERROR;

fapl = h5_fileaccess();
Expand Down
2 changes: 1 addition & 1 deletion test/dt_arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -3261,7 +3261,7 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst)
* The remainder of this function is executed only by the child if
* HANDLE_SIGFPE is defined.
*/
HDsignal(SIGFPE, fpe_handler);
signal(SIGFPE, fpe_handler);

/* What are the names of the source and destination types */
if (H5Tequal(src, H5T_NATIVE_FLOAT)) {
Expand Down
2 changes: 1 addition & 1 deletion test/filenotclosed.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ main(void)
h5_reset();

/* To exit from the file for SIGABRT signal */
if (HDsignal(SIGABRT, catch_signal) == SIG_ERR)
if (signal(SIGABRT, catch_signal) == SIG_ERR)
TEST_ERROR;

fapl = h5_fileaccess();
Expand Down
8 changes: 4 additions & 4 deletions test/h5test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1784,7 +1784,7 @@ h5_send_message(const char *send, const char *arg1, const char *arg2)

fclose(signalfile);

HDrename(TMP_SIGNAL_FILE, send);
rename(TMP_SIGNAL_FILE, send);
} /* h5_send_message() */

/*-------------------------------------------------------------------------
Expand Down Expand Up @@ -2099,8 +2099,8 @@ h5_compare_file_bytes(char *f1name, char *f2name)
}

/* Compare each byte and fail if a difference is found */
HDrewind(f1ptr);
HDrewind(f2ptr);
rewind(f1ptr);
rewind(f2ptr);
for (ii = 0; ii < f1size; ii++) {
if (fread(&f1char, 1, 1, f1ptr) != 1) {
ret_value = -1;
Expand Down Expand Up @@ -2216,7 +2216,7 @@ h5_duplicate_file_by_bytes(const char *orig, const char *dest)

HDfseek(orig_ptr, 0, SEEK_END);
fsize = (size_t)HDftell(orig_ptr);
HDrewind(orig_ptr);
rewind(orig_ptr);

dest_ptr = fopen(dest, "wb");
if (NULL == dest_ptr) {
Expand Down
4 changes: 2 additions & 2 deletions test/tcheck_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ main(int ac, char **av)
(void)_CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, handle_crt_abort);
#endif
parse(ac, av);
HDsignal(SIGABRT, &abort_intercept);
signal(SIGABRT, &abort_intercept);
H5check_version(major, minor, release);
HDsignal(SIGABRT, SIG_DFL);
signal(SIGABRT, SIG_DFL);
#ifdef H5_HAVE_WIN32_API
(void)_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, handle_crt_abort);
#endif
Expand Down
4 changes: 2 additions & 2 deletions testpar/t_2Gio.c
Original file line number Diff line number Diff line change
Expand Up @@ -4270,8 +4270,8 @@ main(int argc, char **argv)

#ifndef H5_HAVE_WIN32_API
/* Un-buffer the stdout and stderr */
HDsetbuf(stderr, NULL);
HDsetbuf(stdout, NULL);
setbuf(stderr, NULL);
setbuf(stdout, NULL);
#endif

MPI_Init(&argc, &argv);
Expand Down
4 changes: 2 additions & 2 deletions testpar/t_shapesame.c
Original file line number Diff line number Diff line change
Expand Up @@ -4283,8 +4283,8 @@ main(int argc, char **argv)

#ifndef H5_HAVE_WIN32_API
/* Un-buffer the stdout and stderr */
HDsetbuf(stderr, NULL);
HDsetbuf(stdout, NULL);
setbuf(stderr, NULL);
setbuf(stdout, NULL);
#endif

#ifdef H5_HAVE_TEST_API
Expand Down
4 changes: 2 additions & 2 deletions testpar/testphdf5.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ main(int argc, char **argv)

#ifndef H5_HAVE_WIN32_API
/* Un-buffer the stdout and stderr */
HDsetbuf(stderr, NULL);
HDsetbuf(stdout, NULL);
setbuf(stderr, NULL);
setbuf(stdout, NULL);
#endif

#ifdef H5_HAVE_TEST_API
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/h5tools_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ parallel_print(const char *format, ...)
/* Terminate the outbuff at the end of the previous output */
outBuff[outBuffOffset] = '\0';

overflow_file = HDtmpfile();
overflow_file = tmpfile();
if (overflow_file == NULL)
fprintf(rawerrorstream,
"warning: could not create overflow file. Output may be truncated.\n");
Expand Down

0 comments on commit a5b3a2f

Please sign in to comment.