diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 4d27d662a65..15d96f607fb 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -408,8 +408,6 @@ CHECK_FUNCTION_EXISTS (getrusage ${HDF_PREFIX}_HAVE_GETRUSAGE) CHECK_FUNCTION_EXISTS (pread ${HDF_PREFIX}_HAVE_PREAD) CHECK_FUNCTION_EXISTS (pwrite ${HDF_PREFIX}_HAVE_PWRITE) -CHECK_FUNCTION_EXISTS (rand_r ${HDF_PREFIX}_HAVE_RAND_R) -CHECK_FUNCTION_EXISTS (random ${HDF_PREFIX}_HAVE_RANDOM) CHECK_FUNCTION_EXISTS (strcasestr ${HDF_PREFIX}_HAVE_STRCASESTR) CHECK_FUNCTION_EXISTS (strdup ${HDF_PREFIX}_HAVE_STRDUP) diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index b3fbede50a3..586032bf269 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -276,12 +276,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_QUADMATH_H @H5_HAVE_QUADMATH_H@ -/* Define to 1 if you have the `random' function. */ -#cmakedefine H5_HAVE_RANDOM @H5_HAVE_RANDOM@ - -/* Define to 1 if you have the `rand_r' function. */ -#cmakedefine H5_HAVE_RAND_R @H5_HAVE_RAND_R@ - /* Define whether the Read-Only S3 virtual file driver (VFD) should be compiled */ #cmakedefine H5_HAVE_ROS3_VFD @H5_HAVE_ROS3_VFD@ diff --git a/configure.ac b/configure.ac index 5fb3718ef1e..b22c8ea21a4 100644 --- a/configure.ac +++ b/configure.ac @@ -2393,7 +2393,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ AC_SEARCH_LIBS([clock_gettime], [rt posix4]) AC_CHECK_FUNCS([asprintf clock_gettime fcntl flock fork]) AC_CHECK_FUNCS([gethostname getrusage gettimeofday]) -AC_CHECK_FUNCS([rand_r random]) AC_CHECK_FUNCS([strcasestr strdup symlink]) AC_CHECK_FUNCS([tmpfile vasprintf waitpid]) diff --git a/doc/getting-started-with-hdf5-development.md b/doc/getting-started-with-hdf5-development.md deleted file mode 100644 index 687a1ea7cca..00000000000 --- a/doc/getting-started-with-hdf5-development.md +++ /dev/null @@ -1,866 +0,0 @@ -# Getting Started with HDF5 Development - -## Introduction - -The purpose of this document is to introduce new HDF5 developers to some of the -quirks of our source code. It's not a style guide (see the forthcoming HDF5 -style guide for that), but instead describes the most commonly encountered -features that are likely to trip up someone who has never worked with the HDF5 -source code before. - -Corrections and suggestions for improvement should be handled via GitHub pull -requests and issues. - -## Getting started - -### Building the library for development - -You don't really need special configuration settings for building the library -as a developer. - -Some tips that may be useful: - -* Building in debug mode will turn on additional checks in many packages. - You'll probably want to start coding in debug mode. -* You can turn symbols on independently of debug/production mode. -* If you will be looking at memory issues via tools like valgrind, you will - need to turn off the free lists, which recycle memory so we can avoid - calling malloc/free. This is done using the `--enable-using-memchecker` - configure option. Some developers build with this all the time, as the - memory recyclilng can hide problems like use-after-free. -* You can enable developer warnings via `--enable-developer-warnings`. These - warnings generate a lot of noise, but the output can occasionally be useful. - I probably wouldn't turn them on all the time, though, as they can make it - harder to spot warnings that we care about. -* You can set warnings as errors. We have an older scheme that does this for - a subset of errors or you can simply specify `-Werror`, etc. as a part of - `CFLAGS`. Configure is smart enough to strip it out when it runs configure - checks. We build the C library with -Werror on GitHub, so you'll need to fix - your warnings before creating a pull request. -* CMake has a developer mode that turns most these settings on. - - -### Branches - -Please see `doc/branches-explained.md` for an explanation of our branching strategy. - -For new small features, we have developers create feature branches in their own -repositories and then create pull requests into the canonical HDF5 repository. -For larger work, especially when the work will be done by multiple people, we -create feature branches named `feature/`. If work stops on a feature -branch, we rename it to `inactive/`. - -If you create a feature branch in the canonical HDFGroup repository, please -create a `BRANCH.md` text file in the repository root and explain: - -* The branch's purpose -* Contact info for someone who can tell us about the branch -* Clues about when the branch will be merged or can be considered for retirement - -The purpose of this document is to avoid orphan branches with no clear -provenance. - - -### Pull requests - -The process of creating a pull request is explained in `CONTRIBUTING.md`. - - -## A brief tour of the source code - -Here's a quick guide to where you can find things in our source tree. Some of these directories have README.md files of their own. - -`bin/` -Scripts we use for building the software and misc. tools. - -`c++/` -Source, tests, and examples for the C++ language wrapper. - -`config/` -Configuration files for both the Autotools and CMake. - -`doc/` -Miscellaneous documents, mostly in markdown format. - -`doxygen/` -Mainly Doxygen build files and other top-level Doxygen things. The Doxygen content is spread across the library's header files but some content can be found here when it has no other obvious home. - -`examples/` -C library examples. Fortran and C++ examples are located in their corresponding wrapper directory. - -`fortran/` -Source, tests, and examples for the Fortran language wrapper. - -`hl/` -Source, tests, and examples for the high-level library. - -`java/` -Source, tests, and examples for the JNI language wrapper and the corresponding OO Java library. - -`m4/` -m4 build scripts used by the Autotools. CMake ignores these. - -`release_docs/` -Install instructions and release notes. - -`src/` -Source code for the C library. - -`test/` -C library test code. Described in much more detail below. - -`testpar/` -Parallel C library test code. Described in much more detail below. - -`tools/` -HDF5 command-line tools code, associated tools tests, and the input test files. - -`utils/` -Small utility programs that don't belong anywhere else. - - -## General Things - -### Necessary software - -In order to do development work on the HDF5 library, you will need to have -a few things available. - -* A C99-compatible C compiler (MSVC counts). C11 is required to build the subfiling feature. -* Either CMake or the Autotools (Autoconf, Automake, libtool) -* Perl is needed to run some scripts, even on Windows -* A C++11-compatible compiler if you want to build the C++ wrappers -* A Fortran 2003-compatible compiler if you want to build the Fortran wrappers -* A Java 8-compatible compiler if you want to build the Java wrappers -* flex/lex and bison/yacc if you want to modify the high-level parsers -* A development version of zlib is necessary for zlib compression -* A development version of szip is necessary for szip compression -* An MPI-3 compatible MPI library must be installed for parallel HDF5 development -* clang-format is handy for formatting your code before submission to GitHub. The formatter will automatically update your PR if it's mis-formatted, though, so this isn't strictly necessary. -* codespell is useful to identify spelling issues before submission to GitHub. The codespell action won't automatically correct your code, but it will point out spelling errors, so this also isn't strictly necessary. - -These are the requirements for working on the develop branch. Maintenance -branches may relax the required versions somewhat. For example, HDF5 1.12 and -earlier only require C++98. - -Certain optional features may require additional libraries to be installed. You'll need curl and some S3 components installed to build the read-only S3 VFD, for example. - -### Platform-independence - -HDF5 assumes you have a C99 compiler and, to a certain extent, a POSIX-like -environment (other languages will be discussed later). On most operating systems -in common use, this will be a reasonable assumption. The biggest exception to -this has been Windows, which, until recently, had poor C99 compliance and spotty -POSIX functionality. To work around differences in platforms and compilers, -we've implemented a compatibility scheme. - -Unlike most codebases, which test for features and inject their own normal-looking -functions when there are deficiencies, HDF5 uses a scheme where we prefix all -C and POSIX calls with `HD` (e.g., `HDmalloc`). The `H5private.h` header handles -most of the fixup for Unix-like operating systems and defines the HD replacements. -For Windows, we first parse the `H5win32defs.h` file, which maps missing Windows -and MSVC functionality to POSIX and C99 calls. `H5private.h` tests for previously -defined HD calls and skips redefining it if it already exists. H5system.c -includes Windows glue code as well as a few functions we need to paper over -differences in Unix-like systems. - -One thing to keep in mind when looking at our platform-independence layer is -that it is quite old, having been authored when the Unix world was much more -fragmented and C99 was uncommon. We've slowly been reworking it as POSIX has -standardized and C99 become widespread. - -Another thing to keep in mind is that we're fairly conservative about deprecating -support for older platforms and compilers. There's an awful lot of ancient -hardware that requires HDF5, so we try to only make major changes to things -like language requirements when we increment the major version (minor version -prior to HDF5 2.0). - -### C99 - -We assume you have a C99 compiler. Subfiling uses some C11 features, but that is -compiled on demand and we are not moving that requirement to the rest of the -library. All modern compilers we've tested can handle HDF5's C99 requirements, -even Microsoft's. In the future, we'll remove the `HD` prefixes from all standard -C library calls. - -One quirk of HDF5's age, is the `hbool_t` type, which was created before C99 -Booleans were widespread and which uses `TRUE` and `FALSE` macros for its values -instead of C99's `true` and `false`. We plan to switch this over to C99's Boolean -types sometime in the near future. - -### POSIX - -We assume basic POSIX.1-2008 functionality is present. When a POSIX (or common Unix) -function is missing on a popular platform, we implement a shim or macro -in `H5private.h` and/or `H5system.c`. Systems that need a lot of help, like -Windows, have gotten special headers in the past (e.g., `H5win32defs.h`) but -now that most platforms implement the POSIX and C99 functionality we need, these -special headers are less necessary. - -### Threads - -Thread-safety was originally implemented using Pthreads, with Win32 support -bolted on later. No other thread libraries are supported. The subfiling -feature uses multiple threads under the hood, but that's out of scope for -an introductory document. Thread-related code is largely confined to the `H5TS` -files, where we define HDF5-specific primitives and then map Pthread or Win32 -implementations onto them. - -### C++ - -The C++ Wrappers require C++11. We generally only require the rule of three -for the classes. - -### Fortran - -The Fortran wrappers require Fortran 2003. - -### Java - -The Java wrappers require Java 8. - -### Warning suppression - -In the rare cases where we've decided to suppress a warning, we have a set -of function-like macros that we use for that. They are located in `H5private.h` -and have the form `H5__DIAG_(OFF|ON)` and take the name of the warning -they are suppressing as a parameter. They were originally designed for gcc and -extended to clang. They have not been updated for other compilers. Instead, -we have plans to revamp the macro system to be more generic and extensible. - -We try to configure the compilers we use the most for maximum grumpiness and -then fix all the warnings we can. Please don't use the warning suppression -macros in lieu of actually fixing the underlying problems. - -## Build Systems - -We support building the library with both the Autotools and CMake. We'd like to -eventually move to only having one build system, which would be CMake since -the Autotools don't really support Windows, but that seems unlikely to happen -anytime soon. With few exceptions, any new feature, test, or configure -option should be supported in both build systems. - -The particulars of the build systems can be found in the `config` directory -and its subdirectories. - -## Working in the library - -### Anatomy of an HDF5 API call - -HDF5 API calls have a uniform structure imposed by our function enter/leave and -error handling schemes. We currently stick to this boilerplate for ALL -functions, though this may change in the future. The general boilerplate varies -slightly between internal and public API calls. - -Here's an example of an internal API call: - -```c -/* - * Function comments of dubious value - */ -herr_t -H5X_do_stuff(/*parameters*/) -{ - /* variables go here */ - void *foo = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - HDassert(/*parameter check*/); - - if (H5X_other_call() < 0) - HGOTO_ERROR(H5E_MAJ, H5E_MIN, FAIL, "badness"); - -done: - if (ret_value < 0) - /* do error cleanup */ - /* do regular cleanup stuff */ - - FUNC_LEAVE_NOAPI(ret_value); -} -``` - -There are a couple of things to note here. - -* Each function call has a header comment block. The information you'll find in - most function comments is not particularly helpful. We're going to improve the - format of this. -* Most functions will return `herr_t` or `hid_t` ID. We try to avoid other - return types and instead use out parameters to return things to the user. -* The name will be of the form `H5X_do_something()` with one or two underscores - after the `H5X`. The naming scheme will be explained later. -* Even though C99 allows declarations anywhere in the function, we put most of - them at the top of the file, with the exception of loop variables and - variables that are "in scope" inside an ifdef. -* We generally initialize values that may need to be freed or otherwise cleaned - up to a "bad" value like `NULL` or `H5I_INVALID_HID` so we can better clean up - resources on function exit, especially when there have been errors. -* Most non-void functions will declare a variable called `ret_value`. This is - used by the error handling macros. It's usually the last thing declared in - the variable block. -* Every function starts with a `FUNC_ENTER macro`, discussed later in this - document. -* Most internal calls will check parameters via asserts. -* We check the return value of any call that can return an error, using the form - shown. -* On errors, an error macro is invoked. These are described later in this - document. -* Any function that returns an error will have a `done` target. Most error - macros jump to this location on errors. -* We do most cleanup at the end of the function, after the `done` target. There - are special `DONE` flavors of error macro that we use in post-`done` cleanup - code to detect and report errors without loops. -* Almost every function ends with a `FUNC_LEAVE` macro. - -And here's an example of a public API call: - -```c -/* - * Doxygen stuff goes here - */ -herr_t -H5Xdo_api_stuff(/*parameters*/) -{ - /* variables go here */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE3(/*stuff*/) - - if (/*parameter check*/) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "badness"); - - /* VOL setup */ - - if (H5VL_call() < 0) - HGOTO_ERROR(H5E_FOO, H5E_BAR, FAIL, "badness"); - -done: - if (ret_value < 0) - /* do error cleanup */ - /* do regular cleanup stuff */ - - FUNC_LEAVE_API(ret_value); -} - -``` - -A public API call differs little from an internal call. The biggest differences: - -* Public API calls are commented using Doxygen. This is how we generate the - reference manual entries. -* The name will have the form `H5Xdo_stuff()`, with no underscores after the `H5X`. -* The function enter macro is `FUNC_ENTER_API` (or similar). Under the hood, this - one differs quite a bit from an internal function enter macro. It checks for - package initialization, for example, and acquires the global lock in thread-safe HDF5. -* There is a `TRACE` macro. This helps with API tracing and is applied by a - script invoked by `autogen.sh` (Autotools) or CMake. You probably don't need - to worry much about this. -* Parameter checking uses the regular HDF5 error scheme and invokes - `HGOTO_ERROR` macros on errors. -* In storage-related calls, there will usually be some VOL setup (HDF5 1.12.x - and later) and in lieu of a regular internal API call, there will be an `H5VL` - VOL call. -* The function exit macro will be `FUNC_LEAVE_API` (or similar). This is where - we release the global thread-safe lock, etc. - - -### Public, private, package - -HDF5 is divided into _packages_, which encapsulate related functionality. Each -has a prefix of the form `H5X(Y)`. An example is the dataset package, which has -the prefix `H5D`. Hopefully, you are familiar with this from the public API. In -addition to the public packages, we all know and love, there are many internal -packages that are not visible to the public via API calls, like `H5FL` (free -lists / memory pools) and `H5B2` (version 2 B-trees). There's also an `H5` -package that deals with very low-level things like library startup. - -API calls, types, etc. in HDF5 have three levels of visibility. From most to -least visible, these are: - -* Public -* Private -* Package - -**Public** things are in the public API. They are usually found in `H5Xpublic.h` -header files. API calls are of the form `H5Xfoo()`, with no underscores between -the package name and the rest of the function name. - -**Private** things are for use across the HDF5 library, and can be used outside the packages -that contain them. They collectively make up the "internal library API". API -calls are of the form `H5X_foo()` with one underscore between the package -name and the rest of the function name. - -**Package** things are for use inside the package and the compiler will -complain if you include them outside of the package they belong to. They -collectively make up the "internal package API". API calls are of the form -`H5X__foo()` with *two* underscores between the package name and the rest of the -function name. The concept of "friend" packages exists and you can declare this -by defining `_FRIEND` in a file. This will let you include the package -header from a package in a file that it is not a member of. Doing this is -strongly discouraged, though. Test functions are often declared in package -headers as they expose package internals and test programs can include -multiple package headers so they can check on internal package state. - -Note that the underscore scheme is primarily for API calls and does not extend -to things like types and symbols. Another thing to keep in mind is that the -difference between package and private API calls can be somewhat arbitrary. -We're hoping to improve the coherence of the internal APIs via refactoring. - - -### Function enter and leave macros - -Function enter and leave macros are added to almost all HDF5 API calls. This is -where we set up error handling (see below) and things like the thread-safety -global lock (in public API calls). There are different flavors depending on the -API call and it's very important that they are appropriate for the function they -mark up. - -The various combinations you are most likely to encounter: - -|Macro|Use| -|-----|---| -|`FUNC_ENTER_API`|Used when entering a public API call| -|`FUNC_ENTER_NOAPI`|Used when entering a private API call| -|`FUNC_ENTER_PACKAGE`|Used when entering a package API call| - -There are also `_NO_INIT` flavors of some of these macros. These are usually -small utility functions that don't initialize the library, like -`H5is_library_threadsafe()`. They are uncommon. - -You may also come across `_NO_FS` ("no function stack") flavors that don't push -themselves on the stack. These are rare. - -For the most part, you will be using the `API`, `NOAPI`, and `PACKAGE` macros. - -You may see other versions if you are working in a maintenance branch, like the -`STATIC` macros that we removed in 1.13. We've been working to reduce the -complexity and number of these macros and we don't always push that downstream -due to the scope of the changes involved. You should be able to figure out what -any new macros do based on what you've seen here, though. - -### Error macros - -Almost all HDF5 functions return an error code, usually -1 or some typedef'd -equivalent. Functions that return `void` should be avoided, even if the function -cannot fail. Instead, return an `herr_t` value and always return `SUCCEED`. - -|Type|Error Value| -|----|-----------| -|`herr_t`|`FAIL`| -|any signed integer type|-1| -|`hid_t`|`H5I_INVALID_HID`| -|`htri_t`|`FAIL`| -|`haddr_t`|`HADDR_UNDEF`| -|pointer|`NULL`| - -We've been trying to move away from using anything other than `herr_t` or `hid_t` -to return errors, as eliminating half of a variable's potential values just so -we can return a 'bad' value on errors seems unwise in a library that is -designed to scale. - -`herr_t` is a typedef'd signed integer. In the library, we only define two -values for it: `SUCCEED` and `FAIL`, which are defined to 0 and -1, respectively, -in `H5private.h`. We do not export these values, so public API calls just note -that `herr_t` values will be negative on failure and non-negative on success. - -Most of the error handling is performed using macros. The only extra setup you -will have to do is: - -1. Create a variable named `ret_value` with the same type -as the return value for the function. If the type is `herr_t` it is frequently -set to `SUCCEED` and will be set to `FAIL` on errors. In most other cases, -the value is initialized to the 'bad' value and the function's code will set -`ret_value` to a 'good' value at some point, with errors setting it back to -the 'bad' value. - -2. Create a done target (`done:`) just before you start your error cleanup. -This will be the point to which the error macros will jump. - -We check for errors on almost all internal lines of C code that could putatively -fail. The general format is this: - -```c -if (function_that_could_fail(foo, bar) < 0) - HGOTO_ERROR(H5E_, H5E_, , "tell me about badness"); -``` - -`HGOTO_ERROR` is one of a set of macros defined in `H5Eprivate.h`. This macro -pops an error on the error stack and sets the return value to ``, -then jumps to the `done:` target. - -Major and minor codes are a frequent cause of confusion. A full list of them -can be found in `H5err.txt`, which is processed into the actual error header -files at configure time by the `bin/make_err` script. The original intent was for major and minor error -codes to be strongly associated. i.e., a given minor code would *only* be used -with its associated major code. Unfortunately, this has not been the case in -practice, and the emitted text can appear nonsensical in error -stack dumps. Even worse, the major and minor error codes are used inconsistently -throughout the library, making interpreting them almost impossible for -external users. We hope to address this deficiency in the near future. - -In the meantime, the following guidelines can be helpful: - -1. Use `H5E_ARGS` as the major error category when parsing function parameters. The minor code will usually be `H5E_BADVALUE`, `H5E_BADRANGE`, or `H5E_BADTYPE`. -2. Otherwise use the same major code throughout the source file. There is almost a 1-1 correspondence between packages and major error codes. -3. Pick the minor code that seems to match the API call. You can grep through the library to find similar uses. -4. The string at the end of the `HGOTO_ERROR` macro is much more important, so make sure that is helpful - -You will still sometimes see the major error code match the package of a failing -function call. We're trying to fix those as we come across them. - -Since the `HGOTO_ERROR` macro jumps to the `done:` target, you can't use it -after the `done:` target without creating a loop. Instead, you'll need to use -the `HDONE_ERROR` macro, which will handle errors without jumping to the target. -Instead, processing will continue after pushing the error and setting the -return value, in the hopes that we can clean up as much as possible. - -At the end of the function, the `FUNC_LEAVE` macro will return `ret_value`. - -### Trace macros - -These are automatically generated for public C library API calls by the -`bin/trace` script, which scans the source code, looking for functions of the -form `H5X(Y?)()`, to which it will add or update the `H5TRACE` macros. - -`H5TRACE` macros are only added to public C library API calls. They are NOT -added to the language wrappers, tools code, high-level library, etc. - -You should never have to modify an `H5TRACE` macro. Either point `bin/trace` at -your source file or run `autogen.sh` (which runs `bin/trace` over the C files -in `src`). `bin/trace` is a Perl script, so you'll need to have that available. - - -### Memory - `H5MM` and `H5FL` - -In the C library itself, we use `H5MM` and `H5FL` calls to allocate and free -memory instead of directly using the standard C library calls. - -The `H5MM` package was originally designed so that it would be easy to swap in a -memory allocator of the developer's choosing. In practice, this has rarely -been a useful feature, and we are thinking about removing this scheme. In -the meantime, almost all memory allocations in the C library will use the -`H5MM` (or `H5FL`) package. - -In the past, we added memory allocation sanity checking to the `H5MM` calls -which added heap canaries to memory allocations and performed sanity checking -and gathered statistics. These were turned on by default in debug builds -for many years. Unfortunately, there is interplay between library-allocated -and externally-allocated memory in the filter pipeline where the heap canaries -can easily get corrupted and cause problems. We also have some API calls that -return library-allocated memory to the user, which can cause problems if they -then use `free(3)` to free it. Given these problems, we now have the sanity -checks turned off by default in all build modes. You can turn them back on via -configure/CMake options, but it's normally easier to use external tools like -valgrind or the compiler's memory debugging options. - -`H5FL` provides memory pools (*Free Lists*) that create a set of fixed-size allocations -of a certain type that the library will reuse as needed. They use `H5MM` calls -under the hood and can be useful when the library creates and frees a lot of -objects of that type. It's difficult to give a good guideline as to when to use -the `H5FL` calls and when to use the `H5MM` calls, but it's probably best to -lean towards `H5MM` unless you can identify a clear performance hit due to -memory cycling. Current library usage can be a good guide, but keep in mind that -the free lists are probably overused in the library. Another thing to keep in -mind is that the free lists can hide memory errors, like use-after-free. Some -developers always turn them off and you'll need to turn them off when running -memory checkers like valgrind. - -Using free list calls differs little from using `H5MM` calls. There are -equivalents for `malloc(3)`, `calloc(3)`, and `free(3)`: - -| C Library|`H5FL`| -|----------|------| -|`malloc`|`H5FL_MALLOC`| -|`calloc`|`H5FL_CALLOC`| -|`free`|`H5FL_FREE`| - -Since free lists provide pre-allocated memory of a fixed size, you can't -reallocate free list memory and there's no `H5FL` `realloc(3)` equivalent. - -You'll also need to add a setup macro to the top of the file. There are a few -flavors defined in `H5FLprivate.h`. Each creates global free list variables, -so there are flavors for extern, static, etc. - -|Macro|Purpose| -|-----|-------| -|`H5FL_DEFINE`|Define a free list that will be used in several files| -|`H5FL_EXTERN`|Define a free list that was defined in another file| -|`H5FL_DEFINE_STATIC`|Define a free list that will only be used in this file| - -You will also see `ARR`, `BLK`, `SEQ`, and `FAC` flavors of the macros. Their -use is beyond the scope of a guide for beginners. - -## Testing - -### Two macro schemes - -The HDF5 C library is tested via a collection of small programs in the `test/` -directory. There are a few schemes in use: - -- `testhdf5` - A larger, composite test program composed of several test files, most of which start with 't' (e.g., `tcoords.c`) -- Shell/Powershell scripts that test things like SWMR and flush/refresh behavior. These scripts run small sub-programs. -- Everything else. These are self-contained test programs that are built and run independently by the test harness. - - -The test programs do not use a standard test framework like cppunit, but instead -use HDF5-specific macros to set up the tests and report errors. There are two -sets of macros, one in `testhdf5.h` and another in `h5test.h`. -Originally, the `testhdf5` programs used the macros in `testhdf5.h` and everything -else used the macros in `h5test.h`, but over time the tests have evolved so that -all tests usually include both headers. - -This is unfortunate, because it's very important to not mix up the "test framework -macros" in each scheme. The `testhdf5.h` macros register errors by setting global -variables and normally continue with the test when they encounter errors. The -`h5test.h` macros indicate errors by jumping to an error target and returning -a `FAIL` `herr_t` value. If you combine these two macro sets, you may -accidentally create tests that fail but do not register the failure. - -We are aware that our testing scheme needs some work and we'll be working to -improve it over the next year or so. - -The command-line tools are tested using a different scheme and are discussed elsewhere. - -### `testhdf5.h` - -The macros in this file are almost exclusively used in the `testhdf5` program. -They register errors by incrementing a global error count that is inspected at -the end of each test (not each test *function*, but each *test* - e.g., after -`test_file()` in `tfile.c` runs, but not when the individual functions it -calls run). - -Test functions generally look like this: - -```c -static void -test_something() -{ - /* Variables go here */ - int out = -1; - herr_t ret; - - MESSAGE(5, ("Testing a thing\n")); - - ret = H5Xsome_api_call(&out); - CHECK(ret, FAIL, "H5Xsome_api_call()"); - VERIFY(out, 6, "incorrect value for out"); -} - -``` - -The `MESSAGE` macro just dumps the name of what we're testing when we've the -verbosity cranked up. The confusingly-named `CHECK` and `VERIFY` macros are -members of a suite of check macros in `testhdf5.h`. `CHECK` macros check to -see if a variable is **NOT** a value, `VERIFY` macros check to see if a variable -**IS** a value. There are different flavors of macro to match different types -so be sure to use the right one to avoid compiler warnings and spurious errors. -Under the hood, these macros will emit error information and increment the -global error variables. - -Tests are added to `testhdf5` in `testhdf5.c` using the `AddTest()` call. -Each test will have a driver function, usually named something like `test_()` -that invokes the test functions in the file. -Most tests will cleanup their files using a `cleanup_()` call. If you are -deleting HDF5 files, you should use `H5Fdelete()` instead of `remove(3)` so -that files can be cleaned even when they use alternative VFDs or VOL connectors. -You'll also need to add prototypes for any new test driver or cleanup functions -to `testhdf5.h`. - -Because these macros interact with global variables that are only used in the -testhdf5 program, they are useless anywhere else in the library. Even worse, it -will *look* like you are testing functionality, but errors will not be picked -up by the non-testhdf5 programs, hiding problems. - -### `h5test.h` - -These are the most commonly used macros and are used throughout the test code, -even in places that are not specifically tests. Unlike the scheme used in -the `testhdf5` program, these macros work more like the library, jumping to -an `error:` target on errors. There is no common `ret_value` variable, however. - -Test functions will usually look like this: - -```c -static herr_t -test_something() -{ - hid_t fapl_id = H5I_INVALID_HID; - hid_t fid = H5I_INVALID_HID; - char filename[1024]; - int *buf = NULL; - - TESTING("Testing some feature"); - - if ((fapl_id = h5_fileaccess()) < 0) - TEST_ERROR; - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) - TEST_ERROR; - - /* Many more calls here */ - - PASSED(); - return SUCCEED; - -error: - - HDfree(buf); - - H5E_BEGIN_TRY - { - H5Fclose(fid); - } - H5E_END_TRY - - return FAIL; -} -``` - -Tests begin with a `TESTING` macro that emits some text (unlike the `testhdf5` -case, this is always dumped). Any errors will be handled by one of the -`TEST_ERROR` macros. For the most part, `TEST_ERROR` will suffice, but there -are others in `h5test.h` if you want to emit custom text, dump the HDF5 error -stack when it would not normally be triggered, etc. - -Most tests will be set up to run with arbitrary VFDs. To do this, you set the -fapl ID using the `h5_fileaccess()` function, which will check the `HDF5_TEST_DRIVER` -environment variable and set the fapl's VFD accordingly. The `h5_fixname()` -call can then be used to get a VFD-appropriate filename for the `H5Fcreate()`, -etc. call. - -In the `error` section, we clean up resources and return a 'bad' value, which -will usually either be `FAIL` or -1. - -The `main()` function of each test program will usually start out by calling -`h5_reset()`, then run each test, incrementing an error count variable if a -test fails. The exit code and text will be set based on the error count. - -### Scripts - -If you need to fire off multiple programs to test a new feature, you may have -to do this via a script. These are normally named `test_.sh.in`. The -`.in` is because the scripts are often modified and copied during the configure -step. In the past, we have tried to stick to POSIX Bourne shell scripts, but -many scripts now require bash. - -If you write a new test script, it is important to also add a PowerShell -equivalent for testing on Windows. - -It's helpful to run any new shell scripts through `shellcheck` -(https://www.shellcheck.net/) to ensure that your scripts are free from -common problems. - - -### Parallel tests (in `testpar/`) - -To be covered in a future update of this guide... - -### Adding new tests - -All new HDF5 library functionality (including bugfixes) should have a test. -Some rules of thumb: - -- If you need to run multiple programs, you'll need to create a script and some test programs. Use the macros in `h5test.h` to handle errors in your test programs. -- If a suitable test program already exists (especially if your tests will be small), add your new tests to the existing file. -- If you need to create a new test program, create one that uses the `h5test.h` macros. -- Avoid adding new tests to `testhdf5` or using the macros in `testhdf5.h`. - -Don't forget that you'll need to add your test program or script to the lists in -both the CMake and Autotools test files (`CMakeLists.txt` and `Makefile.am` in -`test/` respectively). For simple tests, you just need to add your new test to -the list of tests. - -All new tests **MUST** run under both the Autotools and CMake. Ideally, they -should also work on Windows, but we're willing to overlook this for things -that are unlikely to be useful on that platform. - -## Documentation - -We have moved the user guide and reference manual to Doxygen. All public API -calls and symbols should have Doxygen markup in the public header file. New major -features should be documented in the user guide. This Doxygen content is located in -the package's module header file (`H5Xmodule.h`). Language wrapper calls -(C++/Fortran/Java) should also have Doxygen markup, which will be located with -the wrapper source code. Images and other common Doxygen files belong in the -`doxygen` directory. - -Internal documentation for developer consumption is currently stored as Markdown -files in the `doc` directory. This may change in the future. Documentation that -helps understand the contents of a directory is often stored in a README.md -Markdown file in that directory. - -Build and install documentation is stored in text files in `release_docs`. This -is admittedly not the best place for this. History files are also kept here. - -## Command-Line Tools - -The HDF5 command-line tools are written in C and built with the library by default. -The code is organized into a central tools library (in the `tools/lib` directory) -that includes some common functionality and the individual programs, each of which -has its own directory in `tools/src`. A few of the smaller tools are aggregated -into the `tools/src/misc` directory. Only h5diff has a parallel version at this -time and the parallel-specific functionality is in the `tools/src/h5diff/ph5diff_main.c` file. -Some h5diff functionality has also made its way into the tools library. -The tools code is not as well organized as the main library, so there's more opportunity -for refactoring here. - -Also worth noting is that the command-line tools only use **public** HDF5 API -calls, even though they include `H5private.h` in order to take advantage of -the platform-independence scheme we use in the main library and some private -utility functions. - -There are also a few tools in the high-level library. The gif2h5 and h52gif tools -are poorly-written and have known security issues, so they will soon be moved -to a separate repository, leaving h5watch as the only high-level command-line tool. - -### Source code - -The source code for the tools likes more like standard C code and uses its own -set of macros, which are defined in the tools library header files. There are -no `FUNC_ENTER` macros, you do not need to define a `ret_value` variable, -and the error macros are greatly simplified. Errors are usually handled by -a `TOOLS_ERROR` macro (or `TOOLS_GOTO_ERROR` if you need to jump to a `done:` -target to handle cleanup). -One area where the tools need a lot more work is in handling errors. The tools -code frequently ignores errors, often in functions that return `void`. - -A "tools-only" consideration is the use of command-line arguments. We try to -be conservative about these, even though they really aren't in the "public API" -in the same way as API calls are. Additions and changes to the options will -probably result in some discussion. - -### Tools tests - -In most cases, a tool will be run against an input HDF5 file with a particular -set of command-line parameters, the exit code checked, and the output compared -with a standard output file. In some cases, errors are expected and standard -error files will be compared. These standard error files often contain HDF5 -error stack dumps, which can cause spurious tool test "failures" when we -make changes to the main HDF5 C library. - -Test files can be located in a few places in the `tools` directory tree. -Common input files that are used with multiple tools are kept in `tools/testfiles`. -Input files that are used with just one tool are located in `tools/test//testfiles`. -Expected output files are located with their respective HDF5 files and end in `.txt`. -Expected error files are also located with their respective HDF5 files and end in `.err`. -h5dump files will usually have `.ddl` and `.xml` output files and there will -usually be `.` files that contain help output. -The test files are generated by programs with `gentest` in their name, though -we typically check the generated HDF5 files in instead of recreating them -as a part of running the tools tests. - -The Autotools aggregate the tools tests in per-tool shell scripts in the -`tools/test/` directory. Each script starts with a few utility functions -that perform setup, compare files, clean output, etc. and the test commands -will appear at the end. CMake works similarly, but each test is set up in -the CMakeLists.txt and CMakeTests.cmake files in the same directory. - -Adding a new test will usually involve: -- Adding a new function to the appropriate generator program to create a new HDF5 file -- Adding your new test to the CMake and Autotools test scripts, as described above -- Adding appropriate output and/or error files for comparison - -You MUST add new tests to both the Autotools and CMake. diff --git a/doxygen/dox/TechnicalNotes.dox b/doxygen/dox/TechnicalNotes.dox index bca81e4211c..7edf0a0abf7 100644 --- a/doxygen/dox/TechnicalNotes.dox +++ b/doxygen/dox/TechnicalNotes.dox @@ -7,6 +7,8 @@ \li \ref IOFLOW \li \ref TNMDC \li \ref MT +\li \ref SWMR +\li \ref VDS \li \ref VFL */ @@ -45,4 +47,16 @@ \htmlinclude DebuggingHDF5Applications.html -*/ \ No newline at end of file +*/ + +/** \page SWMR Introduction to Single-Writer/Multiple-Reader (SWMR) + +\htmlinclude intro_SWMR.html + +*/ + +/** \page VDS Introduction to the Virtual Dataset - VDS + +\htmlinclude intro_VDS.html + +*/ diff --git a/doxygen/dox/ViewTools.dox b/doxygen/dox/ViewTools.dox index f4c31c83663..92cbd0099b0 100644 --- a/doxygen/dox/ViewTools.dox +++ b/doxygen/dox/ViewTools.dox @@ -997,7 +997,7 @@ In other words, it is an array of four elements, in which each element is a 3 by This dataset is much more complex. Also note that subsetting cannot be done on Array datatypes. -See this FAQ for more information on the Array datatype. +See this section for more information on the Array datatype. \subsubsection subsubsecViewToolsViewDtypes_objref Object Reference An Object Reference is a reference to an entire object (dataset, group, or named datatype). diff --git a/doxygen/examples/intro_SWMR.html b/doxygen/examples/intro_SWMR.html new file mode 100644 index 00000000000..7b7ece3e20f --- /dev/null +++ b/doxygen/examples/intro_SWMR.html @@ -0,0 +1,99 @@ + + + Introduction to Single-Writer_Multiple-Reader (SWMR) + +

Introduction to SWMR

+

The Single-Writer / Multiple-Reader (SWMR) feature enables multiple processes to read an HDF5 file while it is being written to (by a single process) without using locks or requiring communication between processes.

+

All communication between processes must be performed via the HDF5 file. The HDF5 file under SWMR access must reside on a system that complies with POSIX write() semantics.

+

The basic engineering challenge for this to work was to ensure that the readers of an HDF5 file always see a coherent (though possibly not up to date) HDF5 file.

+

The issue is that when writing data there is information in the metadata cache in addition to the physical file on disk:

+

However, the readers can only see the state contained in the physical file:

+

The SWMR solution implements dependencies on when the metadata can be flushed to the file. This ensures that metadata cache flush operations occur in the proper order, so that there will never be internal file pointers in the physical file that point to invalid (unflushed) file addresses.

+

A beneficial side effect of using SWMR access is better fault tolerance. It is more difficult to corrupt a file when using SWMR.

+

Documentation

+

SWMR User's Guide

+

HDF5 Library APIs

+
    +
  • H5F_START_SWMR_WRITE — Enables SWMR writing mode for a file
  • +
  • H5DO_APPEND — Appends data to a dataset along a specified dimension
  • +
  • H5P_SET_OBJECT_FLUSH_CB — Sets a callback function to invoke when an object flush occurs in the file
  • +
  • H5P_GET_OBJECT_FLUSH_CB — Retrieves the object flush property values from the file access property list
  • +
  • H5O_DISABLE_MDC_FLUSHES — Prevents metadata entries for an HDF5 object from being flushed from the metadata cache to storage
  • +
  • H5O_ENABLE_MDC_FLUSHES — Enables flushing of dirty metadata entries from a file’s metadata cache
  • +
  • H5O_ARE_MDC_FLUSHES_DISABLED — Determines if an HDF5 object has had flushes of metadata entries disabled
  • +
+

Tools

+
    +
  • h5watch — Outputs new records appended to a dataset as the dataset grows
  • +
  • h5format_convert — Converts the layout format version and chunked indexing types of datasets created with HDF5-1.10 so that applications built with HDF5-1.8 can access them
  • +
  • h5clear — Clears superblock status_flags field, removes metadata cache image, prints EOA and EOF, or sets EOA of a file
  • +
+

Design Documents

+

Error while fetching page properties report data:

+

Programming Model

+

Please be aware that the SWMR feature requires that an HDF5 file be created with the latest file format. See H5P_SET_LIBVER_BOUNDS for more information.

+

To use SWMR follow the the general programming model for creating and accessing HDF5 files and objects along with the steps described below.

+

SWMR Writer:

+

The SWMR writer either opens an existing file and objects or creates them as follows.

+

Open an existing file:

+

Call H5Fopen using the H5F_ACC_SWMR_WRITE flag. +Begin writing datasets. +Periodically flush data. +Create a new file:

+

Call H5Fcreate using the latest file format. +Create groups, datasets and attributes, and then close the attributes. +Call H5F_START_SWMR_WRITE to start SWMR access to the file. +Periodically flush data.

+

Example Code:

+

Create the file using the latest file format property:

+

fapl = H5Pcreate (H5P_FILE_ACCESS); + status = H5Pset_libver_bounds (fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + fid = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); +[Create objects (files, datasets, ...). Close any attributes and named datatype objects. Groups and datasets may remain open before starting SWMR access to them.]

+

Start SWMR access to the file:

+

status = H5Fstart_swmr_write (fid); +Reopen the datasets and start writing, periodically flushing data:

+

status = H5Dwrite (dset_id, ...); + status = H5Dflush (dset_id);

+

SWMR Reader:

+

The SWMR reader must continually poll for new data:

+

Call H5Fopen using the H5F_ACC_SWMR_READ flag. +Poll, checking the size of the dataset to see if there is new data available for reading. +Read new data, if any.

+

Example Code:

+

Open the file using the SWMR read flag:

+

fid = H5Fopen (filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, H5P_DEFAULT); +Open the dataset and then repeatedly poll the dataset, by getting the dimensions, reading new data, and refreshing:

+

dset_id = H5Dopen (...); + space_id = H5Dget_space (...); + while (...) { + status = H5Dread (dset_id, ...); + status = H5Drefresh (dset_id); + space_id = H5Dget_space (...); + }

+

Limitations and Scope

+

An HDF5 file under SWMR access must reside on a system that complies with POSIX write() semantics. It is also limited in scope as follows:

+

The writer process is only allowed to modify raw data of existing datasets by;

+

Appending data along any unlimited dimension. +Modifying existing data +The following operations are not allowed (and the corresponding HDF5 files will fail):

+

The writer cannot add new objects to the file. +The writer cannot delete objects in the file. +The writer cannot modify or append data with variable length, string or region reference datatypes. +File space recycling is not allowed. As a result the size of a file modified by a SWMR writer may be larger than a file modified by a non-SWMR writer.

+

Tools for Working with SWMR

+

Two new tools, h5watch and h5clear, are available for use with SWMR. The other HDF5 utilities have also been modified to recognize SWMR:

+

The h5watch tool allows a user to monitor the growth of a dataset. +The h5clear tool clears the status flags in the superblock of an HDF5 file. +The rest of the HDF5 tools will exit gracefully but not work with SWMR otherwise.

+

Programming Example

+

A good example of using SWMR is included with the HDF5 tests in the source code. You can run it while reading the file it creates. If you then interrupt the application and reader and look at the resulting file, you will see that the file is still valid. Follow these steps:

+

Download the HDF5-1.10 source code to a local directory on a filesystem (that complies with POSIX write() semantics). Build the software. No special configuration options are needed to use SWMR.

+

Invoke two command terminal windows. In one window go into the bin/ directory of the built binaries. In the other window go into the test/ directory of the HDF5-1.10 source code that was just built.

+

In the window in the test/ directory compile and run use_append_chunk.c. The example writes a three dimensional dataset by planes (with chunks of size 1 x 256 x 256).

+

In the other window (in the bin/ directory) run h5watch on the file created by use_append_chunk.c (use_append_chunk.h5). It should be run while use_append_chunk is executing and you will see valid data displayed with h5watch.

+

Interrupt use_append_chunk while it is running, and stop h5watch.

+

Use h5clear to clear the status flags in the superblock of the HDF5 file (use_append_chunk.h5).

+

View the file with h5dump. You will see that it is a valid file even though the application did not close properly. It will contain data up to the point that it was interrupted.

+ + diff --git a/doxygen/examples/intro_VDS.html b/doxygen/examples/intro_VDS.html new file mode 100644 index 00000000000..5f3e0336e4c --- /dev/null +++ b/doxygen/examples/intro_VDS.html @@ -0,0 +1,70 @@ + + + Introduction to the Virtual Dataset - VDS + +

The HDF5 Virtual Dataset (VDS) feature enables users to access data in a collection of HDF5 files as a single HDF5 dataset and to use the HDF5 APIs to work with that dataset.

+

For example, your data may be collected into four files:

+ +

+ +

You can map the datasets in the four files into a single VDS that can be accessed just like any other dataset:

+ +

+ +

The mapping between a VDS and the HDF5 source datasets is persistent and transparent to an application. If a source file is missing the fill value will be displayed.

+

See the Virtual (VDS) Documentation for complete details regarding the VDS feature.

+

The VDS feature was implemented using hyperslab selection (H5S_SELECT_HYPERSLAB). See the tutorial on Reading From or Writing to a Subset of a Dataset for more information on selecting hyperslabs.

+

Programming Model +To create a Virtual Dataset you simply follow the HDF5 programming model and add a few additional API calls to map the source code datasets to the VDS.

+

Following are the steps for creating a Virtual Dataset:

+

Create the source datasets that will comprise the VDS +Create the VDS: ‐ Define a datatype and dataspace (can be unlimited) +‐ Define the dataset creation property list (including fill value) +‐ (Repeat for each source dataset) Map elements from the source dataset to elements of the VDS: +Select elements in the source dataset (source selection) +Select elements in the virtual dataset (destination selection) +Map destination selections to source selections (see Functions for Working with a VDS)

+

‐ Call H5Dcreate using the properties defined above +Access the VDS as a regular HDF5 dataset +Close the VDS when finished

+

Functions for Working with a VDS +The H5P_SET_VIRTUAL API sets the mapping between virtual and source datasets. This is a dataset creation property list. Using this API will change the layout of the dataset to H5D_VIRTUAL. As with specifying any dataset creation property list, an instance of the property list is created, modified, passed into the dataset creation call and then closed:

+

dcpl = H5Pcreate (H5P_DATASET_CREATE);

+

src_space = H5screate_simple ... + status = H5Sselect_hyperslab (space, ... + status = H5Pset_virtual (dcpl, space, SRC_FILE[i], SRC_DATASET[i], src_space);

+

dset = H5Dcreate2 (file, DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT);

+

status = H5Pclose (dcpl); +There are several other APIs introduced with Virtual Datasets, including query functions. For details see the complete list of HDF5 library APIs that support Virtual Datasets

+

Limitations +This feature requires HDF5-1.10. +The number of source datasets is unlimited. However, there is a limit on the size of each source dataset.

+

Programming Examples +Example 1 +This example creates three HDF5 files, each with a one-dimensional dataset of 6 elements. The datasets in these files are the source datasets that are then used to create a 4 x 6 Virtual Dataset with a fill value of -1. The first three rows of the VDS are mapped to the data from the three source datasets as shown below:

+

In this example the three source datasets are mapped to the VDS with this code:

+
src\_space = H5Screate\_simple (RANK1, dims, NULL);
+for (i = 0; i < 3; i++) {
+    start[0] = (hsize\_t)i;
+    /* Select i-th row in the virtual dataset; selection in the source datasets is the same. */
+    status = H5Sselect\_hyperslab (space, H5S\_SELECT\_SET, start, NULL, count, block);
+    status = H5Pset\_virtual (dcpl, space, SRC\_FILE[i], SRC\_DATASET[i], src\_space);
+}
+
+

After the VDS is created and closed, it is reopened. The property list is then queried to determine the layout of the dataset and its mappings, and the data in the VDS is read and printed.

+

This example is in the HDF5 source code and can be obtained from here:

+

C Example

+

For details on compiling an HDF5 application: [ Compiling HDF5 Applications ]

+

Example 2 +This example shows how to use a C-style printf statement for specifying multiple source datasets as one virtual dataset. Only one mapping is required. In other words only one H5P_SET_VIRTUAL call is needed to map multiple datasets. It creates a 2-dimensional unlimited VDS. Then it re-opens the file, makes queries, and reads the virtual dataset.

+

The source datasets are specified as A-0, A-1, A-2, and A-3. These are mapped to the virtual dataset with one call:

+
status = H5Pset\_virtual (dcpl, vspace, SRCFILE, "/A-%b", src\_space);
+
+

The %b indicates that the block count of the selection in the dimension should be used.

+

C Example

+

For details on compiling an HDF5 application: [ Compiling HDF5 Applications ]

+

Using h5dump with a VDS +The h5dump utility can be used to view a VDS. The h5dump output for a VDS looks exactly like that for any other dataset. If h5dump cannot find a source dataset then the fill value will be displayed.

+

You can determine that a dataset is a VDS by looking at its properties with h5dump -p. It will display each source dataset mapping, beginning with Mapping 0. Below is an excerpt of the output of h5dump -p on the vds.h5 file created in Example 1.You can see that the entire source file a.h5 is mapped to the first row of the /VDS dataset:

+ + diff --git a/doxygen/img/tutr-swmr1.png b/doxygen/img/tutr-swmr1.png new file mode 100755 index 00000000000..711241619d6 Binary files /dev/null and b/doxygen/img/tutr-swmr1.png differ diff --git a/doxygen/img/tutr-swmr2.png b/doxygen/img/tutr-swmr2.png new file mode 100755 index 00000000000..15c6b453a7f Binary files /dev/null and b/doxygen/img/tutr-swmr2.png differ diff --git a/doxygen/img/tutr-swmr3.png b/doxygen/img/tutr-swmr3.png new file mode 100755 index 00000000000..973be56b759 Binary files /dev/null and b/doxygen/img/tutr-swmr3.png differ diff --git a/doxygen/img/tutrvds-ex.png b/doxygen/img/tutrvds-ex.png new file mode 100755 index 00000000000..c9867c9f331 Binary files /dev/null and b/doxygen/img/tutrvds-ex.png differ diff --git a/doxygen/img/tutrvds-map.png b/doxygen/img/tutrvds-map.png new file mode 100755 index 00000000000..9fb2013c3d0 Binary files /dev/null and b/doxygen/img/tutrvds-map.png differ diff --git a/doxygen/img/tutrvds-multimgs.png b/doxygen/img/tutrvds-multimgs.png new file mode 100755 index 00000000000..68328cd62cb Binary files /dev/null and b/doxygen/img/tutrvds-multimgs.png differ diff --git a/doxygen/img/tutrvds-snglimg.png b/doxygen/img/tutrvds-snglimg.png new file mode 100755 index 00000000000..249e56c8483 Binary files /dev/null and b/doxygen/img/tutrvds-snglimg.png differ diff --git a/src/H5Clog_json.c b/src/H5Clog_json.c index 548e7b83d2e..371d48752c9 100644 --- a/src/H5Clog_json.c +++ b/src/H5Clog_json.c @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 */ @@ -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) @@ -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 */ @@ -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 */ @@ -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) @@ -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) @@ -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 */ @@ -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) @@ -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) @@ -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) diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 307629f7718..84a0f25356f 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -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; } diff --git a/src/H5FDcore.c b/src/H5FDcore.c index c74ef5ed28a..f6967e3e3be 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -391,7 +391,7 @@ 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); @@ -399,7 +399,7 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) "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 */ @@ -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); @@ -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 */ diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 677382552e8..c85a6725ec9 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -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); @@ -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); } @@ -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); @@ -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 */ diff --git a/src/H5FDonion.c b/src/H5FDonion.c index 65b7fa51dd8..516295bad5d 100644 --- a/src/H5FDonion.c +++ b/src/H5FDonion.c @@ -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; diff --git a/src/H5FDs3comms.c b/src/H5FDs3comms.c index 2b7b5419c61..bcda801a8dd 100644 --- a/src/H5FDs3comms.c +++ b/src/H5FDs3comms.c @@ -244,7 +244,7 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) if (lowername == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for lowercase name copy."); for (i = 0; i < namelen; i++) - lowername[i] = (char)HDtolower((int)name[i]); + lowername[i] = (char)tolower((int)name[i]); lowername[namelen] = 0; /* If value supplied, copy name, value, and concatenated "name: value". @@ -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); @@ -2172,7 +2172,7 @@ H5FD_s3comms_nlowercase(char *dest, const char *s, size_t len) H5MM_memcpy(dest, s, len); do { len--; - dest[len] = (char)HDtolower((int)dest[len]); + dest[len] = (char)tolower((int)dest[len]); } while (len > 0); } @@ -2264,7 +2264,7 @@ H5FD_s3comms_parse_url(const char *str, parsed_url_t **_purl) strncpy(purl->scheme, curstr, (size_t)len); purl->scheme[len] = '\0'; for (i = 0; i < len; i++) - purl->scheme[i] = (char)HDtolower(purl->scheme[i]); + purl->scheme[i] = (char)tolower(purl->scheme[i]); /* Skip "://" */ tmpstr += 3; diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 274a8ad3462..01a4bfd235e 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -695,7 +695,7 @@ 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); @@ -703,7 +703,7 @@ H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU "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 */ @@ -801,7 +801,7 @@ 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); @@ -809,7 +809,7 @@ H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN "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 */ diff --git a/src/H5Odbg.c b/src/H5Odbg.c index dfc8e878d8f..78bace66392 100644 --- a/src/H5Odbg.c +++ b/src/H5Odbg.c @@ -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 */ diff --git a/src/H5Omtime.c b/src/H5Omtime.c index cd7fba4c05f..66f8d1bf4d4 100644 --- a/src/H5Omtime.c +++ b/src/H5Omtime.c @@ -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); @@ -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); diff --git a/src/H5private.h b/src/H5private.h index 904aa9f3652..4f1ccb92e20 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -685,15 +685,9 @@ typedef off_t h5_stat_size_t; #ifndef HDaccess #define HDaccess(F, M) access(F, M) #endif -#ifndef HDasctime -#define HDasctime(T) asctime(T) -#endif #ifndef HDchdir #define HDchdir(S) chdir(S) #endif -#ifndef HDclock -#define HDclock() clock() -#endif #ifndef HDclose #define HDclose(F) close(F) #endif @@ -703,12 +697,6 @@ typedef off_t h5_stat_size_t; #ifndef HDcreat #define HDcreat(S, M) creat(S, M) #endif -#ifndef HDctime -#define HDctime(T) ctime(T) -#endif -#ifndef HDdifftime -#define HDdifftime(X, Y) difftime(X, Y) -#endif #ifndef HDfdopen #define HDfdopen(N, S) fdopen(N, S) #endif @@ -771,15 +759,9 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDgettimeofday #define HDgettimeofday(S, P) gettimeofday(S, P) #endif -#ifndef HDgmtime -#define HDgmtime(T) gmtime(T) -#endif #ifndef HDisatty #define HDisatty(F) isatty(F) #endif -#ifndef HDlocaltime -#define HDlocaltime(T) localtime(T) -#endif #ifndef HDlseek #define HDlseek(F, O, W) lseek(F, O, W) #endif @@ -789,9 +771,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDmkdir #define HDmkdir(S, M) mkdir(S, M) #endif -#ifndef HDmktime -#define HDmktime(T) mktime(T) -#endif #ifndef HDnanosleep #define HDnanosleep(N, O) nanosleep(N, O) #endif @@ -807,46 +786,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDpwrite #define HDpwrite(F, B, C, O) pwrite(F, B, C, O) #endif - -/* clang-format off */ -#ifdef H5_HAVE_RAND_R -# ifndef HDrandom -# define HDrandom() HDrand() -# endif - H5_DLL int HDrand(void); -# ifndef HDsrandom -# define HDsrandom(S) HDsrand(S) -# endif - H5_DLL void HDsrand(unsigned int seed); -#elif defined(H5_HAVE_RANDOM) -# ifndef HDrand -# define HDrand() random() -# endif -# ifndef HDrandom -# define HDrandom() random() -# endif -# ifndef HDsrand -# define HDsrand(S) srandom(S) -# endif -# ifndef HDsrandom -# define HDsrandom(S) srandom(S) -# endif -#else -# ifndef HDrand -# define HDrand() rand() -# endif -# ifndef HDrandom -# define HDrandom() rand() -# endif -# ifndef HDsrand -# define HDsrand(S) srand(S) -# endif -# ifndef HDsrandom -# define HDsrandom(S) srand(S) -# endif -#endif -/* clang-format on */ - #ifndef HDread #define HDread(F, M, Z) read(F, M, Z) #endif @@ -911,21 +850,9 @@ 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 HDtime -#define HDtime(T) time(T) -#endif #ifndef HDtmpfile #define HDtmpfile() tmpfile() #endif -#ifndef HDtolower -#define HDtolower(C) tolower(C) -#endif -#ifndef HDtoupper -#define HDtoupper(C) toupper(C) -#endif -#ifndef HDtzset -#define HDtzset() tzset() -#endif #ifndef HDunlink #define HDunlink(S) unlink(S) #endif diff --git a/src/H5system.c b/src/H5system.c index 7c540e5bf6b..21135bc5da9 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -93,39 +93,6 @@ HDvasprintf(char **bufp, const char *fmt, va_list _ap) } #endif /* H5_HAVE_VASPRINTF */ -/*------------------------------------------------------------------------- - * Function: HDrand/HDsrand - * - * Purpose: Wrapper function for rand. If rand_r exists on this system, - * use it. - * - * Wrapper function for srand. If rand_r is available, it will keep - * track of the seed locally instead of using srand() which modifies - * global state and can break other programs. - * - * Return: Success: Random number from 0 to RAND_MAX - * - * Failure: Cannot fail. - * - *------------------------------------------------------------------------- - */ -#ifdef H5_HAVE_RAND_R - -static unsigned int g_seed = 42; - -int -HDrand(void) -{ - return rand_r(&g_seed); -} - -void -HDsrand(unsigned int seed) -{ - g_seed = seed; -} -#endif /* H5_HAVE_RAND_R */ - /*------------------------------------------------------------------------- * Function: Pflock * @@ -223,12 +190,12 @@ H5_make_time(struct tm *tm) /* Initialize timezone information */ if (!H5_ntzset) { - HDtzset(); + tzset(); H5_ntzset = true; - } /* end if */ + } /* Perform base conversion */ - if ((time_t)-1 == (the_time = HDmktime(tm))) + if ((time_t)-1 == (the_time = mktime(tm))) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCONVERT, FAIL, "badly formatted modification time message"); /* Adjust for timezones */ @@ -689,7 +656,7 @@ H5_build_extpath(const char *name, char **extpath /*out*/) * Unix: does not apply */ if (H5_CHECK_ABS_DRIVE(name)) { - drive = HDtoupper(name[0]) - 'A' + 1; + drive = toupper(name[0]) - 'A' + 1; retcwd = HDgetdcwd(drive, cwdpath, MAX_PATH_LEN); strncpy(new_name, &name[2], name_len); } @@ -1404,7 +1371,7 @@ H5_strcasestr(const char *haystack, const char *needle) const char *h = haystack; const char *n = needle; /* loop while lowercase strings match, or needle ends */ - while (HDtolower(*h) == HDtolower(*n) && *n) { + while (tolower(*h) == tolower(*n) && *n) { h++; n++; } diff --git a/src/H5timer.c b/src/H5timer.c index ac04d157fe9..badbc659213 100644 --- a/src/H5timer.c +++ b/src/H5timer.c @@ -156,7 +156,7 @@ H5_now(void) now = now_tv.tv_sec; } #else /* H5_HAVE_GETTIMEOFDAY */ - now = HDtime(NULL); + now = time(NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ return (now); @@ -200,7 +200,7 @@ H5_now_usec(void) #else /* H5_HAVE_GETTIMEOFDAY */ /* Cast all values in this expression to uint64_t to ensure that all intermediate calculations * are done in 64 bit, to prevent overflow */ - now = ((uint64_t)HDtime(NULL) * ((uint64_t)1000 * (uint64_t)1000)); + now = ((uint64_t)time(NULL) * ((uint64_t)1000 * (uint64_t)1000)); #endif /* H5_HAVE_GETTIMEOFDAY */ return (now); @@ -238,7 +238,7 @@ H5_get_time(void) ret_value = (double)now_tv.tv_sec + ((double)now_tv.tv_usec / 1000000.0); } #else - ret_value = (double)HDtime(NULL); + ret_value = (double)time(NULL); #endif FUNC_LEAVE_NOAPI(ret_value) diff --git a/test/API/H5_api_test.c b/test/API/H5_api_test.c index ff7ede34038..63dd095fa0f 100644 --- a/test/API/H5_api_test.c +++ b/test/API/H5_api_test.c @@ -143,7 +143,7 @@ main(int argc, char **argv) n_tests_failed_g = 0; n_tests_skipped_g = 0; - seed = (unsigned)HDtime(NULL); + seed = (unsigned)time(NULL); srand(seed); if (NULL == (test_path_prefix = getenv(HDF5_API_TEST_PATH_PREFIX))) diff --git a/test/accum.c b/test/accum.c index cabd4a84c7c..d5b308dad06 100644 --- a/test/accum.c +++ b/test/accum.c @@ -1920,12 +1920,12 @@ test_random_write(H5F_t *f) TESTING("random writes to accumulator"); /* Choose random # seed */ - seed = (unsigned)HDtime(NULL); + seed = (unsigned)time(NULL); #if 0 /* seed = (unsigned)1155438845; */ fprintf(stderr, "Random # seed was: %u\n", seed); #endif - HDsrandom(seed); + srand(seed); /* Allocate space for the segment length buffer */ off = (size_t *)malloc(MAX_RANDOM_SEGMENTS * sizeof(size_t)); @@ -1940,8 +1940,8 @@ fprintf(stderr, "Random # seed was: %u\n", seed); /* Choose random length of segment, allowing for variance */ do { - length += (size_t)(HDrandom() % RAND_SEG_LEN) + 1; - } while ((HDrandom() & 256) >= 128); /* end while */ + length += (size_t)(rand() % RAND_SEG_LEN) + 1; + } while ((rand() & 256) >= 128); /* end while */ /* Check for going off end of buffer */ if ((cur_off + length) > RANDOM_BUF_SIZE) @@ -1972,7 +1972,7 @@ fprintf(stderr, "Random # seed was: %u\n", seed); size_t tmp; /* Temporary holder for offset & length values */ /* Choose value within next few elements to to swap with */ - swap = ((size_t)HDrandom() % 8) + u; + swap = ((size_t)rand() % 8) + u; if (swap >= nsegments) swap = nsegments - 1; diff --git a/test/app_ref.c b/test/app_ref.c index 1315f03c86b..2f093981d9c 100644 --- a/test/app_ref.c +++ b/test/app_ref.c @@ -27,7 +27,7 @@ * 1 to MAX_NINC). Assumes integers i and ninc are in scope. */ #define RAND_INC(id) \ do { \ - ninc = (HDrand() % MAX_NINC) + 1; \ + ninc = (rand() % MAX_NINC) + 1; \ \ for (i = 0; i < ninc; i++) \ if (H5Iinc_ref(ids[id]) != i + 2) \ @@ -89,7 +89,7 @@ main(void) h5_reset(); h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename); - HDsrand((unsigned)HDtime(NULL)); + srand((unsigned)time(NULL)); TESTING("library shutdown with reference count > 1"); diff --git a/test/big.c b/test/big.c index 03c7dd5246f..508cd82469f 100644 --- a/test/big.c +++ b/test/big.c @@ -103,8 +103,8 @@ randll(hsize_t limit, int current_index) /* Generate up to MAX_TRIES random numbers until one of them */ /* does not overlap with any previous writes */ while (overlap != 0 && tries < MAX_TRIES) { - acc = (hsize_t)HDrandom(); - acc *= (hsize_t)HDrandom(); + acc = (hsize_t)rand(); + acc *= (hsize_t)rand(); acc = acc % limit; overlap = 0; @@ -752,12 +752,12 @@ main(int ac, char **av) sparse_support = is_sparse(); /* Choose random # seed */ - seed = (unsigned long)HDtime(NULL); + seed = (unsigned long)time(NULL); #if 0 /* seed = (unsigned long)1155438845; */ fprintf(stderr, "Random # seed was: %lu\n", seed); #endif - HDsrandom((unsigned)seed); + srand((unsigned)seed); /* run VFD-specific test */ if (H5FD_SEC2 == driver) { diff --git a/test/bittests.c b/test/bittests.c index df4273792b1..643964efea4 100644 --- a/test/bittests.c +++ b/test/bittests.c @@ -156,9 +156,9 @@ test_copy(void) TESTING("bit copy operations"); for (i = 0; i < NTESTS; i++) { - s_offset = (size_t)HDrand() % (8 * sizeof v1); - d_offset = (size_t)HDrand() % (8 * sizeof v2); - size = (unsigned)HDrand() % MIN(8 * sizeof(v1), 8 * sizeof(v2)); + s_offset = (size_t)rand() % (8 * sizeof v1); + d_offset = (size_t)rand() % (8 * sizeof v2); + size = (unsigned)rand() % MIN(8 * sizeof(v1), 8 * sizeof(v2)); size = MIN3(size, 8 * sizeof(v1) - s_offset, 8 * sizeof(v2) - d_offset); memset(v1, 0xff, sizeof v1); memset(v2, 0x00, sizeof v2); @@ -277,12 +277,12 @@ test_shift(void) TESTING("bit shift operations"); for (i = 0; i < NTESTS; i++) { - offset = (size_t)HDrand() % (8 * sizeof vector); - size = (size_t)HDrand() % (8 * sizeof(vector) - offset); + offset = (size_t)rand() % (8 * sizeof vector); + size = (size_t)rand() % (8 * sizeof(vector) - offset); /* Don't want size to be 0 */ if (size == 0) continue; - shift_dist = (ssize_t)((size_t)HDrand() % size); + shift_dist = (ssize_t)((size_t)rand() % size); /*-------- LEFT-shift some bits and make sure something was shifted --------*/ memset(vector, 0x00, sizeof vector); @@ -411,8 +411,8 @@ test_increment(void) TESTING("bit increment operations"); for (i = 0; i < NTESTS; i++) { - offset = (size_t)HDrand() % (8 * sizeof vector); - size = (size_t)HDrand() % (8 * sizeof(vector) - offset); + offset = (size_t)rand() % (8 * sizeof vector); + size = (size_t)rand() % (8 * sizeof(vector) - offset); /* Don't want size to be 0 */ if (size == 0) continue; @@ -497,8 +497,8 @@ test_decrement(void) TESTING("bit decrement operations"); for (i = 0; i < NTESTS; i++) { - offset = (size_t)HDrand() % (8 * sizeof vector); - size = (size_t)HDrand() % (8 * sizeof(vector) - offset); + offset = (size_t)rand() % (8 * sizeof vector); + size = (size_t)rand() % (8 * sizeof(vector) - offset); /* Don't want size to be 0 */ if (size == 0) continue; @@ -566,8 +566,8 @@ test_negate(void) TESTING("bit negate operations"); for (i = 0; i < NTESTS; i++) { - offset = (size_t)HDrand() % (8 * sizeof vector); - size = (size_t)HDrand() % (8 * sizeof(vector) - offset); + offset = (size_t)rand() % (8 * sizeof vector); + size = (size_t)rand() % (8 * sizeof(vector) - offset); /* Don't want size to be 0 */ if (size == 0) continue; @@ -665,8 +665,8 @@ test_set(void) TESTING("bit set operations"); for (i = 0; i < NTESTS; i++) { - d_offset = (size_t)HDrand() % (8 * sizeof v2); - size = (size_t)HDrand() % (8 * sizeof(v2)); + d_offset = (size_t)rand() % (8 * sizeof v2); + size = (size_t)rand() % (8 * sizeof(v2)); size = MIN(size, 8 * sizeof(v2) - d_offset); memset(v2, 0x00, sizeof v2); @@ -780,8 +780,8 @@ test_clear(void) TESTING("bit clear operations"); for (i = 0; i < NTESTS; i++) { - d_offset = (size_t)HDrand() % (8 * sizeof v2); - size = (size_t)HDrand() % (8 * sizeof(v2)); + d_offset = (size_t)rand() % (8 * sizeof v2); + size = (size_t)rand() % (8 * sizeof(v2)); size = MIN(size, 8 * sizeof(v2) - d_offset); memset(v2, 0xff, sizeof v2); diff --git a/test/btree2.c b/test/btree2.c index fc7748c7b27..1bf25e9400f 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -2903,12 +2903,12 @@ test_insert_lots(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t herr_t ret; /* Generic error return value */ /* Initialize random number seed */ - curr_time = HDtime(NULL); + curr_time = time(NULL); #if 0 curr_time=1109170019; fprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); #endif - HDsrandom((unsigned)curr_time); + srand((unsigned)curr_time); /* * Test inserting many records into v2 B-tree @@ -2925,7 +2925,7 @@ fprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); /* Shuffle record #'s */ for (u = 0; u < INSERT_MANY; u++) { - swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u; + swap_idx = ((unsigned)rand() % (INSERT_MANY - u)) + u; temp_rec = records[u]; records[u] = records[swap_idx]; records[swap_idx] = temp_rec; @@ -3015,7 +3015,7 @@ fprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); /* Find random records */ for (u = 0; u < FIND_MANY; u++) { /* Pick random record */ - idx = (hsize_t)(HDrandom() % INSERT_MANY); + idx = (hsize_t)(rand() % INSERT_MANY); /* Attempt to find existent record in root of level-4 B-tree */ found = false; @@ -3046,7 +3046,7 @@ fprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); /* Find random records */ for (u = 0; u < FIND_MANY; u++) { /* Pick random record */ - idx = (hsize_t)(HDrandom() % INSERT_MANY); + idx = (hsize_t)(rand() % INSERT_MANY); /* Attempt to find existent record in root of level-4 B-tree */ /* (in increasing order) */ @@ -4973,12 +4973,12 @@ test_update_lots(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t herr_t ret; /* Generic error return value */ /* Initialize random number seed */ - curr_time = HDtime(NULL); + curr_time = time(NULL); #if 0 curr_time = 1451342093; fprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); #endif - HDsrandom((unsigned)curr_time); + srand((unsigned)curr_time); /* * Test inserting many records into v2 B-tree @@ -5000,7 +5000,7 @@ fprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); H5B2_test_rec_t temp_rec; /* Temporary record */ unsigned swap_idx; /* Location to swap with when shuffling */ - swap_idx = ((unsigned)HDrandom() % (INSERT_MANY_REC - u)) + u; + swap_idx = ((unsigned)rand() % (INSERT_MANY_REC - u)) + u; temp_rec = records[u]; records[u] = records[swap_idx]; records[swap_idx] = temp_rec; @@ -5076,7 +5076,7 @@ fprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); /* Find random records */ for (u = 0; u < FIND_MANY_REC; u++) { /* Pick random record */ - find.key = (hsize_t)(HDrandom() % INSERT_MANY_REC); + find.key = (hsize_t)(rand() % INSERT_MANY_REC); find.val = (hsize_t)-1; /* Attempt to find existent record in level-4 B-tree */ @@ -5112,7 +5112,7 @@ fprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); hsize_t idx; /* Record index */ /* Pick random record */ - idx = (hsize_t)(HDrandom() % INSERT_MANY_REC); + idx = (hsize_t)(rand() % INSERT_MANY_REC); /* Reset find record */ find.key = (hsize_t)-1; @@ -8619,12 +8619,12 @@ test_remove_lots(const char *driver_name, hid_t fapl, const H5B2_create_t *cpara bool single_file_vfd; /* Whether VFD used stores data in a single file */ /* Initialize random number seed */ - curr_time = HDtime(NULL); + curr_time = time(NULL); #if 0 curr_time = 1163537969; fprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); #endif - HDsrandom((unsigned)curr_time); + srand((unsigned)curr_time); /* * Test removing many records into v2 B-tree @@ -8643,7 +8643,7 @@ fprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); hsize_t temp_rec; /* Temporary record */ unsigned swap_idx; /* Location to swap with when shuffling */ - swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u; + swap_idx = ((unsigned)rand() % (INSERT_MANY - u)) + u; temp_rec = records[u]; records[u] = records[swap_idx]; records[swap_idx] = temp_rec; @@ -8703,7 +8703,7 @@ fprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); hsize_t temp_rec; /* Temporary record */ unsigned swap_idx; /* Location to swap with when shuffling */ - swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u; + swap_idx = ((unsigned)rand() % (INSERT_MANY - u)) + u; temp_rec = records[u]; records[u] = records[swap_idx]; records[swap_idx] = temp_rec; @@ -8797,7 +8797,7 @@ fprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); /* Remove all records */ for (u = 0; u < INSERT_MANY; u++) { /* Pick a record index to remove from randomly */ - rem_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)); + rem_idx = ((unsigned)rand() % (INSERT_MANY - u)); rrecord = HSIZET_MAX; /* Remove random record */ diff --git a/test/cache_api.c b/test/cache_api.c index de636cf4bb2..5ac6ca0a108 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -1184,9 +1184,9 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) /* do random reads on all datasets */ n = 0; while ((pass) && (n < NUM_RANDOM_ACCESSES)) { - m = HDrand() % NUM_DSETS; - i = (HDrand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE; - j = (HDrand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE; + m = rand() % NUM_DSETS; + i = (rand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE; + j = (rand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE; /* select on disk hyperslab */ offset[0] = (hsize_t)i; /*offset of hyperslab in file*/ @@ -1282,8 +1282,8 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) m = 0; n = 0; while ((pass) && (n < NUM_RANDOM_ACCESSES)) { - i = (HDrand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE; - j = (HDrand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE; + i = (rand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE; + j = (rand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE; /* select on disk hyperslab */ offset[0] = (hsize_t)i; /*offset of hyperslab in file*/ diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index 227b0c3bae9..f19f0c4c87e 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -2831,7 +2831,7 @@ test_pack_ooo(void) * the compound */ unsigned i, j; /* Indices */ - HDsrand((unsigned)HDtime(NULL)); + srand((unsigned)time(NULL)); /* Initialize "free_order" array to indicate that all slots in order are * free */ @@ -2842,7 +2842,7 @@ test_pack_ooo(void) for (i = 0; i < PACK_NMEMBS; i++) { /* Generate index into free_order array */ num_free = PACK_NMEMBS - i; - j = (unsigned)HDrandom() % num_free; + j = (unsigned)rand() % num_free; /* Update order array at the randomly generated (but guaranteed to be * free) location */ @@ -2854,7 +2854,7 @@ test_pack_ooo(void) } /* end for */ /* Generate order to insert inner compound type */ - sub_cmpd_order = (unsigned)HDrandom() % PACK_NMEMBS; + sub_cmpd_order = (unsigned)rand() % PACK_NMEMBS; for (extra_space = 0; extra_space < 2; extra_space++) { if (extra_space) diff --git a/test/dsets.c b/test/dsets.c index 3cc9ccbeae6..90b15dc4134 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -2055,7 +2055,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, for (i = 0; i < size[0]; i++) { for (j = 0; j < size[1] / 2; j++) { - points[i][j] = (int)HDrandom(); + points[i][j] = (int)rand(); } } if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points_data) < 0) @@ -2182,7 +2182,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, for (i = 0; i < (size_t)hs_size[0]; i++) { for (j = 0; j < (size_t)hs_size[1]; j++) { - points[(size_t)hs_offset[0] + i][(size_t)hs_offset[1] + j] = (int)HDrandom(); + points[(size_t)hs_offset[0] + i][(size_t)hs_offset[1] + j] = (int)rand(); } } if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) @@ -3116,7 +3116,7 @@ test_onebyte_shuffle(hid_t file) for (i = 0; i < 10; i++) for (j = 0; j < 20; j++) - orig_data[i][j] = (unsigned char)HDrandom(); + orig_data[i][j] = (unsigned char)rand(); PASSED(); @@ -3232,7 +3232,7 @@ test_nbit_int(hid_t file) for (i = 0; i < (size_t)size[0]; i++) for (j = 0; j < (size_t)size[1]; j++) { power = pow(2.0, (double)(precision - 1)); - orig_data[i][j] = (int)(((long long)HDrandom() % (long long)power) << offset); + orig_data[i][j] = (int)(((long long)rand() % (long long)power) << offset); /* even-numbered values are negative */ if ((i * size[1] + j + 1) % 2 == 0) @@ -3608,9 +3608,8 @@ test_nbit_array(hid_t file) for (j = 0; j < (size_t)size[1]; j++) for (m = 0; m < (size_t)adims[0]; m++) for (n = 0; n < (size_t)adims[1]; n++) { - power = pow(2.0, (double)precision); - orig_data[i][j][m][n] = - (unsigned int)(((long long)HDrandom() % (long long)power) << offset); + power = pow(2.0, (double)precision); + orig_data[i][j][m][n] = (unsigned int)(((long long)rand() % (long long)power) << offset); } /* end for */ PASSED(); @@ -3802,11 +3801,11 @@ test_nbit_compound(hid_t file) for (i = 0; i < (size_t)size[0]; i++) for (j = 0; j < (size_t)size[1]; j++) { power = pow(2.0, (double)(precision[0] - 1)); - orig_data[i][j].i = (int)(((long long)HDrandom() % (long long)power) << offset[0]); + orig_data[i][j].i = (int)(((long long)rand() % (long long)power) << offset[0]); power = pow(2.0, (double)(precision[1] - 1)); - orig_data[i][j].c = (char)(((long long)HDrandom() % (long long)power) << offset[1]); + orig_data[i][j].c = (char)(((long long)rand() % (long long)power) << offset[1]); power = pow(2.0, (double)(precision[2] - 1)); - orig_data[i][j].s = (short)(((long long)HDrandom() % (long long)power) << offset[2]); + orig_data[i][j].s = (short)(((long long)rand() % (long long)power) << offset[2]); orig_data[i][j].f = float_val[i][j]; /* some even-numbered integer values are negative */ @@ -4081,33 +4080,30 @@ test_nbit_compound_2(hid_t file) for (i = 0; i < (size_t)size[0]; i++) for (j = 0; j < (size_t)size[1]; j++) { power = pow(2.0, (double)(precision[0] - 1)); - orig_data[i][j].a.i = (int)(((long long)HDrandom() % (long long)power) << offset[0]); + orig_data[i][j].a.i = (int)(((long long)rand() % (long long)power) << offset[0]); power = pow(2.0, (double)(precision[1] - 1)); - orig_data[i][j].a.c = (char)(((long long)HDrandom() % (long long)power) << offset[1]); + orig_data[i][j].a.c = (char)(((long long)rand() % (long long)power) << offset[1]); power = pow(2.0, (double)(precision[2] - 1)); - orig_data[i][j].a.s = (short)(-(((long long)HDrandom() % (long long)power) << offset[2])); + orig_data[i][j].a.s = (short)(-(((long long)rand() % (long long)power) << offset[2])); orig_data[i][j].a.f = float_val[i][j]; power = pow(2.0, (double)precision[3]); - orig_data[i][j].v = (unsigned int)(((long long)HDrandom() % (long long)power) << offset[3]); + orig_data[i][j].v = (unsigned int)(((long long)rand() % (long long)power) << offset[3]); for (m = 0; m < (size_t)array_dims[0]; m++) for (n = 0; n < (size_t)array_dims[1]; n++) { power = pow(2.0, (double)(precision[4] - 1)); - orig_data[i][j].b[m][n] = (char)(((long long)HDrandom() % (long long)power) << offset[4]); + orig_data[i][j].b[m][n] = (char)(((long long)rand() % (long long)power) << offset[4]); } /* end for */ for (m = 0; m < (size_t)array_dims[0]; m++) for (n = 0; n < (size_t)array_dims[1]; n++) { - power = pow(2.0, (double)(precision[0] - 1)); - orig_data[i][j].d[m][n].i = - (int)(-(((long long)HDrandom() % (long long)power) << offset[0])); - power = pow(2.0, (double)(precision[1] - 1)); - orig_data[i][j].d[m][n].c = - (char)(((long long)HDrandom() % (long long)power) << offset[1]); - power = pow(2.0, (double)(precision[2] - 1)); - orig_data[i][j].d[m][n].s = - (short)(((long long)HDrandom() % (long long)power) << offset[2]); + power = pow(2.0, (double)(precision[0] - 1)); + orig_data[i][j].d[m][n].i = (int)(-(((long long)rand() % (long long)power) << offset[0])); + power = pow(2.0, (double)(precision[1] - 1)); + orig_data[i][j].d[m][n].c = (char)(((long long)rand() % (long long)power) << offset[1]); + power = pow(2.0, (double)(precision[2] - 1)); + orig_data[i][j].d[m][n].s = (short)(((long long)rand() % (long long)power) << offset[2]); orig_data[i][j].d[m][n].f = float_val[i][j]; } /* end for */ } /* end for */ @@ -4335,7 +4331,7 @@ test_nbit_compound_3(hid_t file) for (i = 0; i < (size_t)size[0]; i++) { power = pow(2.0, 17.0 - 1.0); memset(&orig_data[i], 0, sizeof(orig_data[i])); - orig_data[i].i = (int)(HDrandom() % (long)power); + orig_data[i].i = (int)(rand() % (long)power); strcpy(orig_data[i].str, "fixed-length C string"); orig_data[i].vl_str = strdup("variable-length C string"); @@ -4520,7 +4516,7 @@ test_nbit_int_size(hid_t file) for (i = 0; i < DSET_DIM1; i++) for (j = 0; j < DSET_DIM2; j++) { power = pow(2.0, (double)(precision - 1)); - orig[i][j] = HDrandom() % (int)power << offset; + orig[i][j] = rand() % (int)power << offset; } /* Describe the dataspace. */ @@ -4728,7 +4724,7 @@ test_nbit_flt_size(hid_t file) */ for (i = 0; i < DSET_DIM1; i++) for (j = 0; j < DSET_DIM2; j++) - orig[i][j] = (float)(HDrandom() % 1234567) / 2; + orig[i][j] = (float)(rand() % 1234567) / 2; /* Describe the dataspace. */ dims[0] = DSET_DIM1; @@ -4878,7 +4874,7 @@ test_scaleoffset_int(hid_t file) /* Initialize data */ for (i = 0; i < (size_t)size[0]; i++) for (j = 0; j < (size_t)size[1]; j++) { - orig_data[i][j] = HDrandom() % 10000; + orig_data[i][j] = rand() % 10000; /* even-numbered values are negative */ if ((i * size[1] + j + 1) % 2 == 0) @@ -5019,7 +5015,7 @@ test_scaleoffset_int_2(hid_t file) /* Initialize data of hyperslab */ for (j = 0; j < (size_t)size[1]; j++) { - orig_data[0][j] = (int)HDrandom() % 10000; + orig_data[0][j] = (int)rand() % 10000; /* even-numbered values are negative */ if ((j + 1) % 2 == 0) @@ -5138,7 +5134,7 @@ test_scaleoffset_float(hid_t file) /* Initialize data */ for (i = 0; i < (size_t)size[0]; i++) for (j = 0; j < (size_t)size[1]; j++) { - orig_data[i][j] = (float)(HDrandom() % 100000) / 1000.0F; + orig_data[i][j] = (float)(rand() % 100000) / 1000.0F; /* even-numbered values are negative */ if ((i * size[1] + j + 1) % 2 == 0) @@ -5281,7 +5277,7 @@ test_scaleoffset_float_2(hid_t file) /* Initialize data of hyperslab */ for (j = 0; j < (size_t)size[1]; j++) { - orig_data[0][j] = (float)(HDrandom() % 100000) / 1000.0F; + orig_data[0][j] = (float)(rand() % 100000) / 1000.0F; /* even-numbered values are negative */ if ((j + 1) % 2 == 0) @@ -5399,7 +5395,7 @@ test_scaleoffset_double(hid_t file) /* Initialize data */ for (i = 0; i < (size_t)size[0]; i++) for (j = 0; j < (size_t)size[1]; j++) { - orig_data[i][j] = (HDrandom() % 10000000) / 10000000.0; + orig_data[i][j] = (rand() % 10000000) / 10000000.0; /* even-numbered values are negative */ if ((i * size[1] + j + 1) % 2 == 0) @@ -5542,7 +5538,7 @@ test_scaleoffset_double_2(hid_t file) /* Initialize data of hyperslab */ for (j = 0; j < (size_t)size[1]; j++) { - orig_data[0][j] = (HDrandom() % 10000000) / 10000000.0; + orig_data[0][j] = (rand() % 10000000) / 10000000.0; /* even-numbered values are negative */ if ((j + 1) % 2 == 0) @@ -8097,7 +8093,7 @@ make_random_offset_and_increment(long nelts, long *offsetp, long *incp) assert(0 < nelts); - *offsetp = HDrandom() % nelts; + *offsetp = rand() % nelts; /* `maxinc` is chosen so that for any `x` in [0, nelts - 1], * `x + maxinc` does not overflow a long. @@ -8110,7 +8106,7 @@ make_random_offset_and_increment(long nelts, long *offsetp, long *incp) * number. */ do { - inc = 1 + HDrandom() % maxinc; + inc = 1 + rand() % maxinc; } while (gcd(inc, nelts) != 1); *incp = inc; @@ -15921,7 +15917,7 @@ main(void) contig_addr_vfd = (bool)(strcmp(driver_name, "split") != 0 && strcmp(driver_name, "multi") != 0); /* Set the random # seed */ - HDsrandom((unsigned)HDtime(NULL)); + srand((unsigned)time(NULL)); /* Initialize global arrays */ /* points */ diff --git a/test/dt_arith.c b/test/dt_arith.c index 3a91ef19a14..34afdb92132 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -1039,7 +1039,7 @@ test_derived_flt(void) aligned = (int *)calloc((size_t)1, src_size); for (i = 0; i < nelmts * src_size; i++) - buf[i] = saved_buf[i] = (unsigned char)HDrand(); + buf[i] = saved_buf[i] = (unsigned char)rand(); /* Convert data from native integer to derived floating-point type. * The mantissa is big enough to retain the integer's precision. */ @@ -1199,7 +1199,7 @@ test_derived_flt(void) memset(saved_buf, 0, nelmts * src_size); for (i = 0; i < nelmts * src_size; i++) - buf[i] = saved_buf[i] = (unsigned char)HDrand(); + buf[i] = saved_buf[i] = (unsigned char)rand(); /* Convert data from the 2nd to the 1st derived floating-point type. * The mantissa and exponent of the 2nd type are big enough to retain @@ -1520,7 +1520,7 @@ test_derived_integer(void) memset(saved_buf, 0, nelmts * src_size); for (i = 0; i < nelmts * src_size; i++) - buf[i] = saved_buf[i] = (unsigned char)HDrand(); + buf[i] = saved_buf[i] = (unsigned char)rand(); /* Convert data from the 1st to the 2nd derived integer type. * The precision of the 2nd type are big enough to retain @@ -5978,7 +5978,7 @@ main(void) unsigned long nerrors = 0; /* Set the random # seed */ - HDsrandom((unsigned)HDtime(NULL)); + srand((unsigned)time(NULL)); reset_hdf5(); diff --git a/test/dtypes.c b/test/dtypes.c index a7a518e7e88..cebc1b525b5 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -5154,9 +5154,9 @@ test_conv_str_2(void) if (NULL == (buf = (char *)calloc(nelmts, (size_t)8))) goto error; for (i = 0; i < nelmts; i++) { - nchars = (size_t)(HDrand() % 8); + nchars = (size_t)(rand() % 8); for (j = 0; j < nchars; j++) - buf[i * 8 + j] = (char)('a' + HDrand() % 26); + buf[i * 8 + j] = (char)('a' + rand() % 26); while (j < nchars) buf[i * 8 + j++] = '\0'; } /* end for */ @@ -5228,9 +5228,9 @@ test_conv_str_3(void) if (NULL == (buf = (char *)calloc(nelmts, (size_t)8))) FAIL_PUTS_ERROR("Allocation failed."); for (i = 0; i < nelmts; i++) { - nchars = (size_t)(HDrand() % 8); + nchars = (size_t)(rand() % 8); for (j = 0; j < nchars; j++) - buf[i * 8 + j] = (char)('a' + HDrand() % 26); + buf[i * 8 + j] = (char)('a' + rand() % 26); while (j < nchars) buf[i * 8 + j++] = '\0'; } /* end for */ @@ -5367,7 +5367,7 @@ test_conv_enum_1(void) if (NULL == (buf = (int *)malloc(nelmts * MAX(H5Tget_size(t1), H5Tget_size(t2))))) goto error; for (u = 0; u < nelmts; u++) - buf[u] = HDrand() % 26; + buf[u] = rand() % 26; /* Conversions */ snprintf(s, sizeof(s), "Testing random enum conversion O(N)"); @@ -10129,7 +10129,7 @@ main(void) hid_t fapl = H5I_INVALID_HID; /* Set the random # seed */ - HDsrandom((unsigned)HDtime(NULL)); + srand((unsigned)time(NULL)); reset_hdf5(); fapl = h5_fileaccess(); diff --git a/test/earray.c b/test/earray.c index 9cea8f4560a..1402e33d4e1 100644 --- a/test/earray.c +++ b/test/earray.c @@ -1650,7 +1650,7 @@ eiter_rnd_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_par size_t swap_idx; /* Location to swap with when shuffling */ hsize_t temp_idx; /* Temporary index */ - swap_idx = ((size_t)HDrandom() % ((size_t)cnt - u)) + u; + swap_idx = ((size_t)rand() % ((size_t)cnt - u)) + u; temp_idx = eiter->idx[u]; eiter->idx[u] = eiter->idx[swap_idx]; eiter->idx[swap_idx] = temp_idx; @@ -1796,7 +1796,7 @@ eiter_rnd2_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_pa for (u = 0; u < (size_t)cnt; u++) { size_t swap_idx; /* Location to swap with when shuffling */ - swap_idx = ((size_t)HDrandom() % ((size_t)sparse_cnt - u)) + u; + swap_idx = ((size_t)rand() % ((size_t)sparse_cnt - u)) + u; eiter->idx[u] = tmp_idx[swap_idx]; tmp_idx[swap_idx] = tmp_idx[u]; } /* end for */ @@ -2297,7 +2297,6 @@ main(void) earray_iter_type_t curr_iter; /* Current iteration type being worked on */ hid_t fapl = H5I_INVALID_HID; /* File access property list for data files */ unsigned nerrors = 0; /* Cumulative error count */ - time_t curr_time; /* Current time, for seeding random number generator */ int ExpressMode; /* Test express value */ bool api_ctx_pushed = false; /* Whether API context pushed */ @@ -2317,8 +2316,7 @@ main(void) api_ctx_pushed = true; /* Seed random #'s */ - curr_time = HDtime(NULL); - HDsrandom((unsigned)curr_time); + srand((unsigned)time(NULL)); /* Create an empty file to retrieve size */ { diff --git a/test/farray.c b/test/farray.c index 791cb549f1b..12166228d1d 100644 --- a/test/farray.c +++ b/test/farray.c @@ -1149,7 +1149,7 @@ fiter_rnd_init(const H5FA_create_t H5_ATTR_UNUSED *cparam, const farray_test_par size_t swap_idx; /* Location to swap with when shuffling */ hsize_t temp_idx; /* Temporary index */ - swap_idx = ((size_t)HDrandom() % ((size_t)cnt - u)) + u; + swap_idx = ((size_t)rand() % ((size_t)cnt - u)) + u; temp_idx = fiter->idx[u]; fiter->idx[u] = fiter->idx[swap_idx]; fiter->idx[swap_idx] = temp_idx; @@ -1628,7 +1628,6 @@ main(void) farray_iter_type_t curr_iter; /* Current iteration type being worked on */ hid_t fapl = H5I_INVALID_HID; /* File access property list for data files */ unsigned nerrors = 0; /* Cumulative error count */ - time_t curr_time; /* Current time, for seeding random number generator */ int ExpressMode; /* Test express value */ bool api_ctx_pushed = false; /* Whether API context pushed */ @@ -1648,8 +1647,7 @@ main(void) api_ctx_pushed = true; /* Seed random #'s */ - curr_time = HDtime(NULL); - HDsrandom((unsigned)curr_time); + srand((unsigned)time(NULL)); /* Create an empty file to retrieve size */ { diff --git a/test/fheap.c b/test/fheap.c index cd1f0c5ec1f..5f212858456 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -6234,17 +6234,17 @@ test_man_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa fill_size = get_fill_size(tparam); /* Choose random # seed */ - seed = (unsigned long)HDtime(NULL); + seed = (unsigned long)time(NULL); #if 0 /* seed = (unsigned long)1155438845; */ fprintf(stderr, "Random # seed was: %lu\n", seed); #endif - HDsrandom((unsigned)seed); + srand((unsigned)seed); /* Set heap ID to random (non-null) value */ heap_id[0] = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_MAN; for (u = 1; u < HEAP_ID_LEN; u++) - heap_id[u] = (unsigned char)(HDrandom() + 1); + heap_id[u] = (unsigned char)(rand() + 1); /* Try removing bogus heap ID from empty heap */ H5E_BEGIN_TRY @@ -6268,7 +6268,7 @@ fprintf(stderr, "Random # seed was: %lu\n", seed); /* Set heap ID to random (non-null) value */ heap_id[0] = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_MAN; for (u = 1; u < HEAP_ID_LEN; u++) - heap_id[u] = (unsigned char)(HDrandom() + 1); + heap_id[u] = (unsigned char)(rand() + 1); /* Get offset of random heap ID */ if (H5HF_get_id_off_test(fh, heap_id, &obj_off) < 0) @@ -15142,18 +15142,18 @@ test_random(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, fheap_test_pa } /* end else */ /* Choose random # seed */ - seed = (unsigned long)HDtime(NULL); + seed = (unsigned long)time(NULL); #if 0 /* seed = (unsigned long)1156158635; */ fprintf(stderr, "Random # seed was: %lu\n", seed); #endif - HDsrandom((unsigned)seed); + srand((unsigned)seed); /* Loop over adding objects to the heap, until the size limit is reached */ total_obj_added = 0; while (total_obj_added < size_limit) { /* Choose a random size of object (from 1 up to above standalone block size limit) */ - obj_size = (((uint32_t)HDrandom() % (tmp_cparam.max_man_size + 255)) + 1); + obj_size = (((uint32_t)rand() % (tmp_cparam.max_man_size + 255)) + 1); obj_loc = (tmp_cparam.max_man_size + 255) - obj_size; /* Insert object */ @@ -15174,7 +15174,7 @@ fprintf(stderr, "Random # seed was: %lu\n", seed); /* Choose a position to swap with */ /* (0 is current position) */ - pos = ((size_t)HDrandom() % (keep_ids.num_ids - u)); + pos = ((size_t)rand() % (keep_ids.num_ids - u)); /* If we chose a different position, swap with it */ if (pos > 0) { @@ -15345,12 +15345,12 @@ test_random_pow2(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, fheap_te } /* end else */ /* Choose random # seed */ - seed = (unsigned long)HDtime(NULL); + seed = (unsigned long)time(NULL); #if 0 /* seed = (unsigned long)1155181717; */ fprintf(stderr, "Random # seed was: %lu\n", seed); #endif - HDsrandom((unsigned)seed); + srand((unsigned)seed); /* Loop over adding objects to the heap, until the size limit is reached */ total_obj_added = 0; @@ -15362,13 +15362,13 @@ fprintf(stderr, "Random # seed was: %lu\n", seed); * 25% of the objects will be twice as large, 12.5% will be * four times larger, etc.) */ - while (HDrandom() < (RAND_MAX / 2) && size_range < tmp_cparam.max_man_size) + while (rand() < (RAND_MAX / 2) && size_range < tmp_cparam.max_man_size) size_range *= 2; if (size_range > (tmp_cparam.max_man_size + 255)) size_range = tmp_cparam.max_man_size + 255; /* Choose a random size of object (from 1 up to stand alone block size) */ - obj_size = (((unsigned)HDrandom() % (size_range - 1)) + 1); + obj_size = (((unsigned)rand() % (size_range - 1)) + 1); obj_loc = (tmp_cparam.max_man_size + 255) - obj_size; /* Insert object */ @@ -15389,7 +15389,7 @@ fprintf(stderr, "Random # seed was: %lu\n", seed); /* Choose a position to swap with */ /* (0 is current position) */ - pos = ((size_t)HDrandom() % (keep_ids.num_ids - u)); + pos = ((size_t)rand() % (keep_ids.num_ids - u)); /* If we chose a different position, swap with it */ if (pos > 0) { diff --git a/test/fillval.c b/test/fillval.c index c8f46387b74..64a33e04ff8 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -920,7 +920,7 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, H5D_f goto error; for (i = 0; i < 1000; i++) { for (j = 0; j < 5; j++) - hs_offset[j] = (hsize_t)HDrand() % cur_size[j]; + hs_offset[j] = (hsize_t)rand() % cur_size[j]; if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) goto error; @@ -1073,7 +1073,7 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, H5D_f goto error; for (i = 0; i < 1000; i++) { for (j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = (hsize_t)HDrand() % cur_size[j]; + hs_offset[j] = (hsize_t)rand() % cur_size[j]; odd += (int)(hs_offset[j] % 2); } /* end for */ if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) @@ -1644,7 +1644,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, const hsize_t for (i = 0; i < 1000; i++) { /* Set offset for random element */ for (j = 0; j < 5; j++) - hs_offset[j] = (hsize_t)HDrand() % start_size[j]; + hs_offset[j] = (hsize_t)rand() % start_size[j]; /* Select the random element */ if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) @@ -1705,7 +1705,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, const hsize_t for (i = 0; i < 1000; i++) { /* Set offset for random element */ for (j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = (hsize_t)HDrand() % start_size[j]; + hs_offset[j] = (hsize_t)rand() % start_size[j]; odd += (unsigned)(hs_offset[j] % 2); } /* end for */ @@ -1750,7 +1750,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, const hsize_t for (i = 0; i < 1000; i++) { /* Set offset for random element */ for (j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = (hsize_t)HDrand() % extend_size[j]; + hs_offset[j] = (hsize_t)rand() % extend_size[j]; if (hs_offset[j] >= start_size[j]) odd = 1; else @@ -1796,7 +1796,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, const hsize_t for (i = 0; i < 1000; i++) { /* Set offset for random element */ for (j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = (hsize_t)HDrand() % max_size[j]; + hs_offset[j] = (hsize_t)rand() % max_size[j]; if (hs_offset[j] >= start_size[j]) odd = 1; else @@ -1844,7 +1844,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, const hsize_t for (i = 0; i < 1000; i++) { /* Set offset for random element */ for (j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = (hsize_t)HDrand() % extend_size[j]; + hs_offset[j] = (hsize_t)rand() % extend_size[j]; if (hs_offset[j] >= start_size[j]) odd = 1; else @@ -1952,7 +1952,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, const hsize_t for (i = 0; i < 1000; i++) { /* Set offset for random element */ for (j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = (hsize_t)HDrand() % extend_size[j]; + hs_offset[j] = (hsize_t)rand() % extend_size[j]; if (hs_offset[j] >= start_size[j]) odd = 1; else diff --git a/test/filter_plugin.c b/test/filter_plugin.c index 9207d9e847c..4e4f86b41e3 100644 --- a/test/filter_plugin.c +++ b/test/filter_plugin.c @@ -294,7 +294,7 @@ ensure_filter_works(hid_t fid, const char *name, hid_t dcpl_id) for (i = 0; i < r; i++) for (j = 0; j < c / 2; j++) - orig[i][j] = (int)HDrandom() % RANDOM_LIMIT; + orig[i][j] = (int)rand() % RANDOM_LIMIT; if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl_id, *orig) < 0) TEST_ERROR; @@ -349,7 +349,7 @@ ensure_filter_works(hid_t fid, const char *name, hid_t dcpl_id) hs_offc = (size_t)hs_offsets_g[1]; for (i = 0; i < hs_r; i++) for (j = 0; j < hs_c; j++) - orig[hs_offr + i][hs_offc + j] = (int)HDrandom() % RANDOM_LIMIT; + orig[hs_offr + i][hs_offc + j] = (int)rand() % RANDOM_LIMIT; if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offsets_g, NULL, hs_sizes_g, NULL) < 0) TEST_ERROR; diff --git a/test/h5test.c b/test/h5test.c index ba68918c2a1..a472dc9d5c5 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -1820,18 +1820,18 @@ h5_wait_message(const char *waitfor) /* Start timer. If this function runs for too long (i.e., expected signal is never received), it will return failure */ - HDtime(&t0); + time(&t0); /* Wait for return signal from some other process */ while ((returnfile = fopen(waitfor, "r")) == NULL) { /* make note of current time. */ - HDtime(&t1); + time(&t1); /* If we've been waiting for a signal for too long, then it was likely never sent and we should fail rather than loop infinitely */ - if (HDdifftime(t1, t0) > MESSAGE_TIMEOUT) { + if (difftime(t1, t0) > MESSAGE_TIMEOUT) { fprintf(stdout, "Error communicating between processes. Make sure test script is running.\n"); TEST_ERROR; } /* end if */ diff --git a/test/hyperslab.c b/test/hyperslab.c index 03b0e9a152b..16298331122 100644 --- a/test/hyperslab.c +++ b/test/hyperslab.c @@ -1063,9 +1063,9 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z) /* Check offsets */ for (u = 0; u < n; u++) { /* Get random coordinate */ - coords[0] = (hsize_t)((size_t)HDrandom() % z); - coords[1] = (hsize_t)((size_t)HDrandom() % y); - coords[2] = (hsize_t)((size_t)HDrandom() % x); + coords[0] = (hsize_t)((size_t)rand() % z); + coords[1] = (hsize_t)((size_t)rand() % y); + coords[2] = (hsize_t)((size_t)rand() % x); /* Get offset of coordinate */ off = H5VM_array_offset(ARRAY_OFFSET_NDIMS, dims, coords); @@ -1144,7 +1144,7 @@ main(int argc, char *argv[]) printf("\n"); /* Set the random # seed */ - HDsrandom((unsigned)HDtime(NULL)); + srand((unsigned)time(NULL)); /* * Open the library explicitly for thread-safe builds, so per-thread diff --git a/test/istore.c b/test/istore.c index 2062e9486b4..1934cc37b0b 100644 --- a/test/istore.c +++ b/test/istore.c @@ -480,9 +480,9 @@ test_sparse(hid_t f, const char *prefix, size_t nblocks, size_t nx, size_t ny, s TEST_ERROR; for (ctr = 0; ctr < nblocks; ctr++) { - offset[0] = (hsize_t)(HDrandom() % (int)(TEST_SPARSE_SIZE - nx)); - offset[1] = (hsize_t)(HDrandom() % (int)(TEST_SPARSE_SIZE - ny)); - offset[2] = (hsize_t)(HDrandom() % (int)(TEST_SPARSE_SIZE - nz)); + offset[0] = (hsize_t)(rand() % (int)(TEST_SPARSE_SIZE - nx)); + offset[1] = (hsize_t)(rand() % (int)(TEST_SPARSE_SIZE - ny)); + offset[2] = (hsize_t)(rand() % (int)(TEST_SPARSE_SIZE - nz)); /* Select region in file dataspace */ if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, offset, NULL, size, NULL) < 0) @@ -582,7 +582,7 @@ main(int argc, char *argv[]) printf("\n"); /* Set the random # seed */ - HDsrandom((unsigned)HDtime(NULL)); + srand((unsigned)time(NULL)); /* Check to see if the file system supports POSIX-style sparse files. * Windows NTFS does not, so we want to avoid tests which create diff --git a/test/links.c b/test/links.c index 4ea612ebdfd..ffac35651de 100644 --- a/test/links.c +++ b/test/links.c @@ -1770,8 +1770,8 @@ test_move_preserves(hid_t fapl_id, bool new_format) old_modification_time = oinfo.mtime; /* If this test happens too quickly, the times will all be the same. Make sure the time changes. */ - curr_time = HDtime(NULL); - while (HDtime(NULL) <= curr_time) + curr_time = time(NULL); + while (time(NULL) <= curr_time) ; /* Close the file and reopen it */ @@ -2603,8 +2603,8 @@ test_move_preserves_deprec(hid_t fapl_id, bool new_format) old_modification_time = oinfo.mtime; /* If this test happens too quickly, the times will all be the same. Make sure the time changes. */ - curr_time = HDtime(NULL); - while (HDtime(NULL) <= curr_time) + curr_time = time(NULL); + while (time(NULL) <= curr_time) ; /* Close the file and reopen it */ diff --git a/test/mdset.c b/test/mdset.c index 013eb775553..0091bc26e79 100644 --- a/test/mdset.c +++ b/test/mdset.c @@ -310,7 +310,7 @@ test_mdset(size_t niter, unsigned flags, hid_t fapl_id) for (i = 0; i < niter; i++) { /* Determine number of datasets */ ndsets = (flags & MDSET_FLAG_MLAYOUT) ? 6 - : (flags & MDSET_FLAG_MDSET) ? (size_t)((size_t)HDrandom() % max_dsets) + 1 + : (flags & MDSET_FLAG_MDSET) ? (size_t)((size_t)rand() % max_dsets) + 1 : 1; /* Create file */ @@ -325,16 +325,16 @@ test_mdset(size_t niter, unsigned flags, hid_t fapl_id) (flags & MDSET_FLAG_CHUNK) || ((flags & MDSET_FLAG_MLAYOUT) && (j == 1 || j == 2)); /* Generate file dataspace */ - dset_dims[j][0] = (hsize_t)((HDrandom() % MAX_DSET_X) + 1); - dset_dims[j][1] = (hsize_t)((HDrandom() % MAX_DSET_Y) + 1); + dset_dims[j][0] = (hsize_t)((rand() % MAX_DSET_X) + 1); + dset_dims[j][1] = (hsize_t)((rand() % MAX_DSET_Y) + 1); if ((file_space_ids[j] = H5Screate_simple(2, dset_dims[j], use_chunk ? max_dims : NULL)) < 0) TEST_ERROR; /* Generate chunk if called for by configuration (multi layout uses chunked for datasets * 1 and 2) */ if (use_chunk) { - chunk_dims[0] = (hsize_t)((HDrandom() % MAX_CHUNK_X) + 1); - chunk_dims[1] = (hsize_t)((HDrandom() % MAX_CHUNK_Y) + 1); + chunk_dims[0] = (hsize_t)((rand() % MAX_CHUNK_X) + 1); + chunk_dims[1] = (hsize_t)((rand() % MAX_CHUNK_Y) + 1); if (H5Pset_chunk(dcpl_id[j], 2, chunk_dims) < 0) TEST_ERROR; } /* end if */ @@ -352,18 +352,18 @@ test_mdset(size_t niter, unsigned flags, hid_t fapl_id) /* Create dataset */ /* If MDSET_FLAG_TCONV is set, use a different datatype with 50% probability, so * some datasets require type conversion and others do not */ - if ((dset_ids[j] = H5Dcreate2(file_id, dset_name[j], - (flags & MDSET_FLAG_TCONV && HDrandom() % 2) ? H5T_NATIVE_LONG - : H5T_NATIVE_UINT, - file_space_ids[j], H5P_DEFAULT, dcpl_id[j], H5P_DEFAULT)) < 0) + if ((dset_ids[j] = + H5Dcreate2(file_id, dset_name[j], + (flags & MDSET_FLAG_TCONV && rand() % 2) ? H5T_NATIVE_LONG : H5T_NATIVE_UINT, + file_space_ids[j], H5P_DEFAULT, dcpl_id[j], H5P_DEFAULT)) < 0) TEST_ERROR; /* Create virtual source dataset if necessary. Use dcpl_id[0] for a contiguous dataset */ if ((flags & MDSET_FLAG_MLAYOUT) && (j == 6)) { if ((source_dset = H5Dcreate2(file_id, SOURCE_DS_NAME, - (flags & MDSET_FLAG_TCONV && HDrandom() % 2) ? H5T_NATIVE_LONG - : H5T_NATIVE_UINT, + (flags & MDSET_FLAG_TCONV && rand() % 2) ? H5T_NATIVE_LONG + : H5T_NATIVE_UINT, file_space_ids[j], H5P_DEFAULT, dcpl_id[0], H5P_DEFAULT)) < 0) TEST_ERROR; if (H5Dclose(source_dset) < 0) @@ -388,7 +388,7 @@ test_mdset(size_t niter, unsigned flags, hid_t fapl_id) for (j = 0; j < OPS_PER_FILE; j++) { /* Decide whether to read or write. Can't read on the first iteration with external * layout because the write is needed to create the external file. */ - do_read = (j == 0 && flags & MDSET_FLAG_MLAYOUT) ? false : (bool)(HDrandom() % 2); + do_read = (j == 0 && flags & MDSET_FLAG_MLAYOUT) ? false : (bool)(rand() % 2); /* Loop over datasets */ for (k = 0; k < ndsets; k++) { @@ -401,10 +401,10 @@ test_mdset(size_t niter, unsigned flags, hid_t fapl_id) TEST_ERROR; /* Decide whether to do a hyperslab, point, or all selection */ - sel_type = HDrandom() % 3; + sel_type = rand() % 3; if (sel_type == 0) { /* Hyperslab */ - size_t nhs = (size_t)((HDrandom() % MAX_HS) + 1); /* Number of hyperslabs */ + size_t nhs = (size_t)((rand() % MAX_HS) + 1); /* Number of hyperslabs */ size_t max_hs_x = (MAX_HS_X <= dset_dims[k][0]) ? MAX_HS_X : dset_dims[k][0]; /* Determine maximum hyperslab size in X */ @@ -414,14 +414,14 @@ test_mdset(size_t niter, unsigned flags, hid_t fapl_id) for (l = 0; l < nhs; l++) { /* Generate hyperslab */ - count[0] = (hsize_t)(((hsize_t)HDrandom() % max_hs_x) + 1); - count[1] = (hsize_t)(((hsize_t)HDrandom() % max_hs_y) + 1); + count[0] = (hsize_t)(((hsize_t)rand() % max_hs_x) + 1); + count[1] = (hsize_t)(((hsize_t)rand() % max_hs_y) + 1); start[0] = (count[0] == dset_dims[k][0]) ? 0 - : (hsize_t)HDrandom() % (dset_dims[k][0] - count[0] + 1); + : (hsize_t)rand() % (dset_dims[k][0] - count[0] + 1); start[1] = (count[1] == dset_dims[k][1]) ? 0 - : (hsize_t)HDrandom() % (dset_dims[k][1] - count[1] + 1); + : (hsize_t)rand() % (dset_dims[k][1] - count[1] + 1); /* Select hyperslab */ if (H5Sselect_hyperslab(mem_space_ids[k], H5S_SELECT_OR, start, NULL, count, NULL) < @@ -445,12 +445,12 @@ test_mdset(size_t niter, unsigned flags, hid_t fapl_id) } /* end if */ else if (sel_type == 1) { /* Point selection */ - size_t npoints = (size_t)(((size_t)HDrandom() % MAX_POINTS) + 1); /* Number of points */ + size_t npoints = (size_t)(((size_t)rand() % MAX_POINTS) + 1); /* Number of points */ /* Generate points */ for (l = 0; l < npoints; l++) { - points[2 * l] = (unsigned)((hsize_t)HDrandom() % dset_dims[k][0]); - points[(2 * l) + 1] = (unsigned)((hsize_t)HDrandom() % dset_dims[k][1]); + points[2 * l] = (unsigned)((hsize_t)rand() % dset_dims[k][0]); + points[(2 * l) + 1] = (unsigned)((hsize_t)rand() % dset_dims[k][1]); } /* end for */ /* Select points in file */ @@ -646,7 +646,7 @@ main(void) fapl_id = h5_fileaccess(); /* Initialize random number seed */ - HDsrandom((unsigned)HDtime(NULL)); + srand((unsigned)time(NULL)); /* Fill dset_name array */ for (i = 0; i < MAX_DSETS; i++) { diff --git a/test/mtime.c b/test/mtime.c index 60bfaaaadc7..fad164b9e9c 100644 --- a/test/mtime.c +++ b/test/mtime.c @@ -64,7 +64,7 @@ main(void) TEST_ERROR; if ((dset = H5Dcreate2(file, "dset", H5T_NATIVE_SCHAR, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - now = HDtime(NULL); + now = time(NULL); if (H5Dclose(dset) < 0) TEST_ERROR; if (H5Sclose(space) < 0) @@ -110,11 +110,11 @@ main(void) puts(" cannot be queried on this system. See H5O_mtime_decode()."); return 0; } - else if (fabs(HDdifftime(now, oi1.ctime)) > 60.0) { + else if (fabs(difftime(now, oi1.ctime)) > 60.0) { H5_FAILED(); - tm = HDlocaltime(&(oi1.ctime)); + tm = localtime(&(oi1.ctime)); strftime((char *)buf1, sizeof buf1, "%Y-%m-%d %H:%M:%S", tm); - tm = HDlocaltime(&now); + tm = localtime(&now); strftime((char *)buf2, sizeof buf2, "%Y-%m-%d %H:%M:%S", tm); printf(" got: %s\n ans: %s\n", buf1, buf2); goto error; diff --git a/test/ntypes.c b/test/ntypes.c index 5d6b37164b8..3b5bd662bcc 100644 --- a/test/ntypes.c +++ b/test/ntypes.c @@ -3080,7 +3080,7 @@ test__Float16(hid_t file) /* Initialize the data */ for (size_t i = 0; i < DIM0; i++) for (size_t j = 0; j < DIM1; j++) - ipoints->arr[i][j] = (H5__Float16)(HDrand() / (double)RAND_MAX); + ipoints->arr[i][j] = (H5__Float16)(rand() / (double)RAND_MAX); /* Create the data space */ dims[0] = DIM0; diff --git a/test/select_io_dset.c b/test/select_io_dset.c index 2f440d8eec0..3daa63f2d38 100644 --- a/test/select_io_dset.c +++ b/test/select_io_dset.c @@ -1165,9 +1165,8 @@ test_multi_dsets_no_bkg(hid_t fid, unsigned set_cache, unsigned chunked, unsigne chunked ? "chunked" : "contig", dtrans ? "xform" : "noxform", mwbuf ? "mwbuf" : "nomwbuf"); /* Create ith dataset */ - if ((dset_dids[i] = - H5Dcreate2(fid, dset_names[i], ((HDrandom() % 2) ? H5T_NATIVE_LONG : H5T_NATIVE_INT), - file_sids[i], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dset_dids[i] = H5Dcreate2(fid, dset_names[i], ((rand() % 2) ? H5T_NATIVE_LONG : H5T_NATIVE_INT), + file_sids[i], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR; } @@ -1651,7 +1650,7 @@ test_multi_dsets_cmpd_with_bkg(hid_t fid, unsigned chunked, unsigned mwbuf) } /* Case c */ - mm = HDrandom() % (int)ndsets; + mm = rand() % (int)ndsets; if (!mm) mm++; @@ -2401,7 +2400,7 @@ test_multi_dsets_all(int niter, hid_t fid, unsigned chunked, unsigned mwbuf) if ((mem_sids[i] = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR; - mm = HDrandom() % (int)ndsets; + mm = rand() % (int)ndsets; if (mm == 0) { dset_types[i] = DSET_WITH_NO_CONV; snprintf(dset_names[i], sizeof(dset_names[i]), "multi_all_nconv_dset%d_%s_%s", i, diff --git a/test/set_extent.c b/test/set_extent.c index 018421df45f..696ef96f36d 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -119,7 +119,7 @@ main(void) contig_addr_vfd = (bool)(strcmp(driver_name, "split") != 0 && strcmp(driver_name, "multi") != 0); /* Initialize random number seed */ - HDsrandom((unsigned)HDtime(NULL)); + srand((unsigned)time(NULL)); h5_reset(); fapl = h5_fileaccess(); @@ -2345,17 +2345,16 @@ test_random_rank4(hid_t fapl, hid_t dcpl, hid_t dxpl, bool do_fillvalue, bool di /* Generate random chunk dimensions, 2-4 */ for (i = 0; i < 4; i++) - cdims[i] = (hsize_t)((HDrandom() % 3) + 2); + cdims[i] = (hsize_t)((rand() % 3) + 2); /* Pick iteration to shrink dataset to 1x1x1x1 */ - scalar_iter = (unsigned)(HDrandom() % RAND4_NITER); + scalar_iter = (unsigned)(rand() % RAND4_NITER); /* Generate initial dataset size, 1-10, unless using fixed array index or * scalar_iter is 0 */ for (i = 0; i < 4; i++) { dims[i] = - (hsize_t)(index_type != RANK4_INDEX_FARRAY ? (0 == scalar_iter ? 1 : ((HDrandom() % 10) + 1)) - : 10); + (hsize_t)(index_type != RANK4_INDEX_FARRAY ? (0 == scalar_iter ? 1 : ((rand() % 10) + 1)) : 10); dim_log->arr[0][i] = dims[i]; } /* end for */ @@ -2389,7 +2388,7 @@ test_random_rank4(hid_t fapl, hid_t dcpl, hid_t dxpl, bool do_fillvalue, bool di for (k = 0; k < dims[1]; k++) for (l = 0; l < dims[2]; l++) for (m = 0; m < dims[3]; m++) - wbuf->arr[j][k][l][m] = HDrandom(); + wbuf->arr[j][k][l][m] = rand(); /* Write data */ if (H5Dwrite(dset, H5T_NATIVE_INT, mspace, H5S_ALL, dxpl, wbuf) < 0) @@ -2401,8 +2400,8 @@ test_random_rank4(hid_t fapl, hid_t dcpl, hid_t dxpl, bool do_fillvalue, bool di zero_dim = false; for (j = 0; j < 4; j++) { old_dims[j] = dims[j]; - if ((dims[j] = (hsize_t)(i == scalar_iter ? 1 : (HDrandom() % 11))) == 0) - if ((dims[j] = (hsize_t)(HDrandom() % 11)) == 0) + if ((dims[j] = (hsize_t)(i == scalar_iter ? 1 : (rand() % 11))) == 0) + if ((dims[j] = (hsize_t)(rand() % 11)) == 0) zero_dim = true; dim_log->arr[i + 1][j] = dims[j]; } /* end for */ @@ -2592,17 +2591,16 @@ test_random_rank4_vl(hid_t fapl, hid_t dcpl, hid_t dxpl, bool do_fillvalue, bool /* Generate random chunk dimensions, 2-4 */ for (i = 0; i < 4; i++) - cdims[i] = (hsize_t)((HDrandom() % 3) + 2); + cdims[i] = (hsize_t)((rand() % 3) + 2); /* Pick iteration to shrink dataset to 1x1x1x1 */ - scalar_iter = (unsigned)(HDrandom() % RAND4_NITER); + scalar_iter = (unsigned)(rand() % RAND4_NITER); /* Generate initial dataset size, 1-10, unless using fixed array index or * scalar_iter is 0 */ for (i = 0; i < 4; i++) { dims[i] = - (hsize_t)(index_type != RANK4_INDEX_FARRAY ? (0 == scalar_iter ? 1 : ((HDrandom() % 10) + 1)) - : 10); + (hsize_t)(index_type != RANK4_INDEX_FARRAY ? (0 == scalar_iter ? 1 : ((rand() % 10) + 1)) : 10); dim_log->arr[0][i] = dims[i]; } @@ -2649,8 +2647,8 @@ test_random_rank4_vl(hid_t fapl, hid_t dcpl, hid_t dxpl, bool do_fillvalue, bool for (k = 0; k < dims[1]; k++) for (l = 0; l < dims[2]; l++) for (m = 0; m < dims[3]; m++) { - ((int *)wbuf->arr[j][k][l][m].p)[0] = HDrandom(); - ((int *)wbuf->arr[j][k][l][m].p)[1] = HDrandom(); + ((int *)wbuf->arr[j][k][l][m].p)[0] = rand(); + ((int *)wbuf->arr[j][k][l][m].p)[1] = rand(); } /* end for */ /* Write data */ @@ -2663,8 +2661,8 @@ test_random_rank4_vl(hid_t fapl, hid_t dcpl, hid_t dxpl, bool do_fillvalue, bool zero_dim = false; for (j = 0; j < 4; j++) { old_dims[j] = dims[j]; - if ((dims[j] = (hsize_t)(i == scalar_iter ? 1 : (HDrandom() % 11))) == 0) - if ((dims[j] = (hsize_t)(HDrandom() % 11)) == 0) + if ((dims[j] = (hsize_t)(i == scalar_iter ? 1 : (rand() % 11))) == 0) + if ((dims[j] = (hsize_t)(rand() % 11)) == 0) zero_dim = true; dim_log->arr[i + 1][j] = dims[j]; } diff --git a/test/stab.c b/test/stab.c index 357f7682712..3f4a8360bec 100644 --- a/test/stab.c +++ b/test/stab.c @@ -296,7 +296,7 @@ test_large(hid_t fcpl, hid_t fapl, bool new_format) if (H5G__has_stab_test(cwg) != false) TEST_ERROR; for (i = 0; i < LARGE_NOBJS; i++) { - snprintf(name, sizeof(name), "%05d%05d", (HDrandom() % 100000), i); + snprintf(name, sizeof(name), "%05d%05d", (rand() % 100000), i); if ((dir = H5Gcreate2(cwg, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; if (H5Gclose(dir) < 0) diff --git a/test/swmr_addrem_writer.c b/test/swmr_addrem_writer.c index 8fd907af5db..8e42f2436fc 100644 --- a/test/swmr_addrem_writer.c +++ b/test/swmr_addrem_writer.c @@ -172,7 +172,7 @@ addrem_records(hid_t fid, unsigned verbose, unsigned long nops, unsigned long fl symbol = choose_dataset(); /* Decide whether to shrink or expand, and by how much */ - count[1] = (hsize_t)HDrandom() % (MAX_SIZE_CHANGE * 2) + 1; + count[1] = (hsize_t)rand() % (MAX_SIZE_CHANGE * 2) + 1; if (count[1] > MAX_SIZE_CHANGE) { /* Add records */ @@ -359,7 +359,7 @@ main(int argc, char *argv[]) HDgettimeofday(&t, NULL); random_seed = (unsigned)(t.tv_usec); } /* end if */ - HDsrandom(random_seed); + srand(random_seed); /* ALWAYS emit the random seed for possible debugging */ fprintf(stderr, "Using writer random seed: %u\n", random_seed); diff --git a/test/swmr_common.c b/test/swmr_common.c index dd7dd8edd18..b95bdf67b56 100644 --- a/test/swmr_common.c +++ b/test/swmr_common.c @@ -102,10 +102,10 @@ choose_dataset(void) unsigned offset; /* The "offset" of the dataset at that level */ /* Determine level of dataset */ - level = symbol_mapping[HDrandom() % NMAPPING]; + level = symbol_mapping[rand() % NMAPPING]; /* Determine the offset of the level */ - offset = (unsigned)(HDrandom() % (int)symbol_count[level]); + offset = (unsigned)(rand() % (int)symbol_count[level]); return &symbol_info[level][offset]; } /* end choose_dataset() */ diff --git a/test/swmr_generator.c b/test/swmr_generator.c index 0259a30c66c..f66ab03cd52 100644 --- a/test/swmr_generator.c +++ b/test/swmr_generator.c @@ -195,7 +195,7 @@ gen_skeleton(const char *filename, bool verbose, bool swmr_write, int comp_level * moved out of chunk #0 of the object header * (Set to true for every fourth dataset) */ - move_dataspace_message = !(HDrandom() % 4); + move_dataspace_message = !(rand() % 4); if (move_dataspace_message) { unsigned chunk_num; /* Object header chunk # for dataspace message */ @@ -336,7 +336,7 @@ main(int argc, char *argv[]) HDgettimeofday(&t, NULL); random_seed = (unsigned)(t.tv_usec); } /* end if */ - HDsrandom(random_seed); + srand(random_seed); /* ALWAYS emit the random seed for possible debugging */ fprintf(stderr, "Using generator random seed (used in sparse test only): %u\n", random_seed); diff --git a/test/swmr_reader.c b/test/swmr_reader.c index 18f204dee31..93ba920f73c 100644 --- a/test/swmr_reader.c +++ b/test/swmr_reader.c @@ -228,7 +228,7 @@ read_records(const char *filename, bool verbose, FILE *verbose_file, unsigned ra /* Determine the offset of the symbol, within level 0 symbols */ /* (level 0 symbols are the most common symbols) */ - offset = (unsigned)((unsigned)HDrandom() % symbol_count[0]); + offset = (unsigned)((unsigned)rand() % symbol_count[0]); sym_com[v] = &symbol_info[0][offset]; /* Emit informational message */ @@ -267,7 +267,7 @@ read_records(const char *filename, bool verbose, FILE *verbose_file, unsigned ra fprintf(verbose_file, "Reading records\n"); /* Get the starting time */ - start_time = HDtime(NULL); + start_time = time(NULL); curr_time = start_time; /* Create file access property list */ @@ -336,7 +336,7 @@ read_records(const char *filename, bool verbose, FILE *verbose_file, unsigned ra HDsleep(poll_time); /* Retrieve the current time */ - curr_time = HDtime(NULL); + curr_time = time(NULL); } /* end while */ /* Close the memory dataspace */ @@ -475,7 +475,7 @@ main(int argc, char *argv[]) HDgettimeofday(&t, NULL); random_seed = (unsigned)(t.tv_usec); } /* end if */ - HDsrandom(random_seed); + srand(random_seed); /* Open output file */ if (verbose) { diff --git a/test/swmr_remove_reader.c b/test/swmr_remove_reader.c index 614aed2cfa6..ee5a4df2a7f 100644 --- a/test/swmr_remove_reader.c +++ b/test/swmr_remove_reader.c @@ -108,7 +108,7 @@ check_dataset(hid_t fid, unsigned verbose, const char *sym_name, symbol_t *recor if (snpoints > 0) { /* Choose a random record in the dataset, choosing the last record half * the time */ - start[1] = (hsize_t)(HDrandom() % (snpoints * 2)); + start[1] = (hsize_t)(rand() % (snpoints * 2)); if (start[1] > (hsize_t)(snpoints - 1)) start[1] = (hsize_t)(snpoints - 1); if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) @@ -223,7 +223,7 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, uns /* Determine the offset of the symbol, within level 0 symbols */ /* (level 0 symbols are the most common symbols) */ - offset = (unsigned)HDrandom() % symbol_count[0]; + offset = (unsigned)rand() % symbol_count[0]; sym_com[v] = &symbol_info[0][offset]; /* Emit informational message */ @@ -262,7 +262,7 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, uns fprintf(stderr, "Reading records\n"); /* Get the starting time */ - start_time = HDtime(NULL); + start_time = time(NULL); curr_time = start_time; /* Create file access property list */ @@ -322,7 +322,7 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, uns HDsleep(poll_time); /* Retrieve the current time */ - curr_time = HDtime(NULL); + curr_time = time(NULL); } /* end while */ /* Close the fapl */ @@ -466,7 +466,7 @@ main(int argc, char *argv[]) HDgettimeofday(&t, NULL); random_seed = (unsigned)(t.tv_usec); } /* end if */ - HDsrandom(random_seed); + srand(random_seed); /* ALWAYS emit the random seed for possible debugging */ fprintf(stderr, "Using reader random seed: %u\n", random_seed); diff --git a/test/swmr_remove_writer.c b/test/swmr_remove_writer.c index f0d531d30a0..7b4eaeb29ef 100644 --- a/test/swmr_remove_writer.c +++ b/test/swmr_remove_writer.c @@ -158,7 +158,7 @@ remove_records(hid_t fid, unsigned verbose, unsigned long nshrinks, unsigned lon symbol = choose_dataset(); /* Shrink the dataset's dataspace */ - remove_size = (hsize_t)HDrandom() % MAX_REMOVE_SIZE + 1; + remove_size = (hsize_t)rand() % MAX_REMOVE_SIZE + 1; if (remove_size > symbol->nrecords) symbol->nrecords = 0; else @@ -297,7 +297,7 @@ main(int argc, char *argv[]) HDgettimeofday(&t, NULL); random_seed = (unsigned)(t.tv_usec); } /* end if */ - HDsrandom(random_seed); + srand(random_seed); /* ALWAYS emit the random seed for possible debugging */ fprintf(stderr, "Using writer random seed: %u\n", random_seed); diff --git a/test/swmr_sparse_reader.c b/test/swmr_sparse_reader.c index a6d8fd49d38..d2771e83618 100644 --- a/test/swmr_sparse_reader.c +++ b/test/swmr_sparse_reader.c @@ -106,7 +106,7 @@ check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t /* Choose the random record in the dataset (will be the same as chosen by * the writer) */ - start[1] = (hsize_t)HDrandom() % symbol->nrecords; + start[1] = (hsize_t)rand() % symbol->nrecords; if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) return -1; @@ -205,7 +205,7 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, uns return -1; if (H5Aclose(aid) < 0) return -1; - HDsrandom(seed); + srand(seed); /* Reset the record */ /* (record's 'info' field might need to change for each record written, also) */ @@ -220,7 +220,7 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, uns fprintf(stderr, "Reading records\n"); /* Get the starting time */ - start_time = HDtime(NULL); + start_time = time(NULL); /* Read records */ for (u = 0; u < nrecords; u++) { @@ -257,7 +257,7 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, uns } /* end if */ /* Check for timeout */ - if (HDtime(NULL) >= (time_t)(start_time + (time_t)TIMEOUT)) { + if (time(NULL) >= (time_t)(start_time + (time_t)TIMEOUT)) { fprintf(stderr, "Reader timed out\n"); return -1; } /* end if */ diff --git a/test/swmr_sparse_writer.c b/test/swmr_sparse_writer.c index 88d0b51daac..4662d027ee1 100644 --- a/test/swmr_sparse_writer.c +++ b/test/swmr_sparse_writer.c @@ -102,7 +102,7 @@ open_skeleton(const char *filename, unsigned verbose) return -1; if (H5Aclose(aid) < 0) return -1; - HDsrandom(seed); + srand(seed); /* Open the datasets */ for (u = 0; u < NLEVELS; u++) @@ -208,7 +208,7 @@ add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long f } /* end else */ /* Get the coordinate to write */ - start[1] = (hsize_t)HDrandom() % symbol->nrecords; + start[1] = (hsize_t)rand() % symbol->nrecords; /* Set the record's ID (equal to its position) */ record.rec_id = start[1]; diff --git a/test/swmr_start_write.c b/test/swmr_start_write.c index 6254da8b8c9..575e8b67baf 100644 --- a/test/swmr_start_write.c +++ b/test/swmr_start_write.c @@ -442,7 +442,7 @@ main(int argc, char *argv[]) HDgettimeofday(&t, NULL); random_seed = (unsigned)(t.tv_usec); } /* end if */ - HDsrandom(random_seed); + srand(random_seed); /* Open output file */ if (verbose) { diff --git a/test/swmr_writer.c b/test/swmr_writer.c index 7fe1a31284a..5ef6afc50e5 100644 --- a/test/swmr_writer.c +++ b/test/swmr_writer.c @@ -350,7 +350,7 @@ main(int argc, char *argv[]) HDgettimeofday(&t, NULL); random_seed = (unsigned)(t.tv_usec); } /* end if */ - HDsrandom(random_seed); + srand(random_seed); /* Open output file */ if (verbose) { diff --git a/test/tid.c b/test/tid.c index bf557fa34da..da8700f4f74 100644 --- a/test/tid.c +++ b/test/tid.c @@ -638,7 +638,7 @@ rct_free_cb(void *_obj, void H5_ATTR_UNUSED **_ctx) * and then scanning through the list to find that nth unfreed * object. */ - remove_nth = HDrandom() % obj->list->remaining; + remove_nth = rand() % obj->list->remaining; for (i = 0; i < obj->list->count; i++) if (obj->list->objects[i].nfrees == 0) { if (remove_nth == 0) @@ -727,7 +727,7 @@ test_remove_clear_type(void) /* The number of objects used is a random number between the min and max */ obj_list.count = obj_list.remaining = - RCT_MIN_NOBJS + (HDrandom() % (long)(RCT_MAX_NOBJS - RCT_MIN_NOBJS + 1)); + RCT_MIN_NOBJS + (rand() % (long)(RCT_MAX_NOBJS - RCT_MIN_NOBJS + 1)); /* Create the actual objects */ for (j = 0; j < obj_list.count; j++) { @@ -744,7 +744,7 @@ test_remove_clear_type(void) goto error; /* Bump the reference count by 1 (to 2) 50% of the time */ - if (HDrandom() % 2) { + if (rand() % 2) { ret = H5Iinc_ref(objects[j].id); CHECK(ret, FAIL, "H5Iinc_ref"); if (ret == FAIL) @@ -1373,7 +1373,7 @@ void test_ids(void) { /* Set the random # seed */ - HDsrandom((unsigned)HDtime(NULL)); + srand((unsigned)time(NULL)); if (basic_id_test() < 0) TestErrPrintf("Basic ID test failed\n"); diff --git a/test/tselect.c b/test/tselect.c index e07b1b62dfb..5167aba7e06 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -6318,7 +6318,6 @@ test_select_hyper_union_random_5d(hid_t read_plist) herr_t ret; /* Generic return value */ hssize_t npoints, /* Number of elements in file selection */ npoints2; /* Number of elements in memory selection */ - unsigned seed; /* Random number seed for each test */ unsigned test_num; /* Count of tests being executed */ /* Output message about test being performed */ @@ -6362,31 +6361,26 @@ test_select_hyper_union_random_5d(hid_t read_plist) CHECK(sid2, FAIL, "H5Screate_simple"); /* Get initial random # seed */ - seed = (unsigned)HDtime(NULL) + (unsigned)HDclock(); + srand((unsigned)time(NULL)); /* Crunch through a bunch of random hyperslab reads from the file dataset */ for (test_num = 0; test_num < NRAND_HYPER; test_num++) { - /* Save random # seed for later use */ - /* (Used in case of errors, to regenerate the hyperslab sequence) */ - seed += (unsigned)HDclock(); - HDsrandom(seed); - for (i = 0; i < NHYPERSLABS; i++) { /* Select random hyperslab location & size for selection */ for (j = 0; j < SPACE5_RANK; j++) { - start[j] = ((hsize_t)HDrandom() % dims1[j]); - count[j] = (((hsize_t)HDrandom() % (dims1[j] - start[j])) + 1); - } /* end for */ + start[j] = ((hsize_t)rand() % dims1[j]); + count[j] = (((hsize_t)rand() % (dims1[j] - start[j])) + 1); + } /* Select hyperslab */ ret = H5Sselect_hyperslab(sid1, (i == 0 ? H5S_SELECT_SET : H5S_SELECT_OR), start, NULL, count, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); if (ret < 0) { - TestErrPrintf("Random hyperslabs for seed %u failed!\n", seed); + TestErrPrintf("Random hyperslabs failed!\n"); break; - } /* end if */ - } /* end for */ + } + } /* Get the number of elements selected */ npoints = H5Sget_select_npoints(sid1); @@ -6405,17 +6399,17 @@ test_select_hyper_union_random_5d(hid_t read_plist) ret = H5Dread(dataset, H5T_NATIVE_INT, sid2, sid1, read_plist, rbuf); CHECK(ret, FAIL, "H5Dread"); if (ret < 0) { - TestErrPrintf("Random hyperslabs for seed %u failed!\n", seed); + TestErrPrintf("Random hyperslabs failed!\n"); break; - } /* end if */ + } /* Compare data read with data written out */ tbuf = rbuf; ret = H5Diterate(wbuf, H5T_NATIVE_INT, sid1, test_select_hyper_iter2, &tbuf); if (ret < 0) { - TestErrPrintf("Random hyperslabs for seed %u failed!\n", seed); + TestErrPrintf("Random hyperslabs failed!\n"); break; - } /* end if */ + } /* Set the read buffer back to all zeroes */ memset(rbuf, 0, (size_t)SPACE6_DIM1); diff --git a/test/tskiplist.c b/test/tskiplist.c index 7d4cda0dd29..25ee35c0418 100644 --- a/test/tskiplist.c +++ b/test/tskiplist.c @@ -55,10 +55,9 @@ tst_rev_sort(const void *i1, const void *i2) static void test_skiplist_init(void) { - time_t curr_time; /* Current time, for seeding random number generator */ - int new_val; /* New value to insert */ - unsigned found; /* Flag to indicate value was inserted already */ - size_t u, v; /* Local index variables */ + int new_val; /* New value to insert */ + unsigned found; /* Flag to indicate value was inserted already */ + size_t u, v; /* Local index variables */ /* Allocate arrays */ rand_num = (int *)malloc(sizeof(int) * NUM_ELEMS); @@ -69,8 +68,7 @@ test_skiplist_init(void) CHECK_PTR(rev_sort_rand_num, "malloc"); /* Initialize random number seed */ - curr_time = HDtime(NULL); - HDsrandom((unsigned)curr_time); + srand((unsigned)time(NULL)); /* Create randomized set of numbers */ for (u = 0; u < NUM_ELEMS; u++) { @@ -79,7 +77,7 @@ test_skiplist_init(void) found = 0; /* Generate random numbers from -5000 to 5000 */ - new_val = (int)(HDrandom() % 10001) - 5001; + new_val = (int)(rand() % 10001) - 5001; /* Check if the value is already in the array */ for (v = 0; v < u; v++) diff --git a/test/ttime.c b/test/ttime.c index 32e6859018f..08e9f967ab7 100644 --- a/test/ttime.c +++ b/test/ttime.c @@ -150,7 +150,7 @@ test_time_io(void) CHECK(dsid, FAIL, "H5Dcreate2"); /* Initialize time data value */ - timenow = HDtime(NULL); + timenow = time(NULL); /* Write time to dataset */ status = H5Dwrite(dsid, H5T_UNIX_D32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &timenow); @@ -182,7 +182,7 @@ test_time_io(void) status = H5Dread(dsid, H5T_UNIX_D32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &timethen); CHECK(status, FAIL, "H5Dread"); - fprintf(stderr, "time written was: %s\n", HDctime(&timethen)); + fprintf(stderr, "time written was: %s\n", ctime(&timethen)); status = H5Dclose(dsid); CHECK(status, FAIL, "H5Dclose"); diff --git a/test/tunicode.c b/test/tunicode.c index a65b469a8a8..62ce82da804 100644 --- a/test/tunicode.c +++ b/test/tunicode.c @@ -815,14 +815,14 @@ test_unicode(void) MESSAGE(5, ("Testing UTF-8 Encoding\n")); /* Create a random string with length NUM_CHARS */ - HDsrandom((unsigned)HDtime(NULL)); + srand((unsigned)time(NULL)); memset(test_string, 0, sizeof(test_string)); for (x = 0; x < NUM_CHARS; x++) { /* We need to avoid unprintable characters (codes 0-31) and the * . and / characters, since they aren't allowed in path names. */ - unicode_point = (unsigned)(HDrandom() % (MAX_CODE_POINT - 32)) + 32; + unicode_point = (unsigned)(rand() % (MAX_CODE_POINT - 32)) + 32; if (unicode_point != 46 && unicode_point != 47) cur_pos = write_char(unicode_point, test_string, cur_pos); } diff --git a/test/unlink.c b/test/unlink.c index ae8da98b491..a722c21fbc3 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -816,7 +816,7 @@ test_filespace(hid_t fapl) /* Set buffer to different random numbers each time */ for (v = 0, tmp_data = data; v < (FILESPACE_DIM0 * FILESPACE_DIM1 * FILESPACE_DIM2); v++) - *tmp_data++ = (int)HDrandom(); + *tmp_data++ = (int)rand(); /* Write the buffer to the dataset */ if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) @@ -2906,7 +2906,7 @@ main(void) double rdcc_w0; /* Set the random # seed */ - HDsrandom((unsigned)HDtime(NULL)); + srand((unsigned)time(NULL)); /* Open */ h5_reset(); diff --git a/test/vds_swmr_writer.c b/test/vds_swmr_writer.c index 752cc509e24..b57c2f689dd 100644 --- a/test/vds_swmr_writer.c +++ b/test/vds_swmr_writer.c @@ -112,8 +112,8 @@ main(int argc, char *argv[]) TEST_ERROR; /* Wait one second between writing planes */ - delay = HDtime(0) + (time_t)1; - while (HDtime(0) < delay) + delay = time(0) + (time_t)1; + while (time(0) < delay) ; /* Flush */ diff --git a/test/vfd.c b/test/vfd.c index 7025de907df..9f33e0ea328 100644 --- a/test/vfd.c +++ b/test/vfd.c @@ -3461,7 +3461,7 @@ setup_rand(void) fprintf(stdout, "\n%s: predefined_seed = %d.\n\n", __func__, seed); fflush(stdout); - HDsrand(seed); + srand(seed); } else { @@ -3477,7 +3477,7 @@ setup_rand(void) fprintf(stdout, "\n%s: seed = %d.\n\n", __func__, seed); fflush(stdout); - HDsrand(seed); + srand(seed); } } diff --git a/testpar/API/H5_api_test_parallel.c b/testpar/API/H5_api_test_parallel.c index 224c1b8a7c4..71264af418c 100644 --- a/testpar/API/H5_api_test_parallel.c +++ b/testpar/API/H5_api_test_parallel.c @@ -223,7 +223,7 @@ main(int argc, char **argv) n_tests_skipped_g = 0; if (MAINPROCESS) { - seed = (unsigned)HDtime(NULL); + seed = (unsigned)time(NULL); } if (mpi_size > 1) { diff --git a/testpar/t_cache.c b/testpar/t_cache.c index 0f845ef9b39..162b8f31679 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -2883,7 +2883,7 @@ local_pin_and_unpin_random_entries(H5F_t *file_ptr, int min_idx, int max_idx, in assert(0 <= min_count); assert(min_count < max_count); - count = (HDrand() % (max_count - min_count)) + min_count; + count = (rand() % (max_count - min_count)) + min_count; assert(min_count <= count); assert(count <= max_count); @@ -2892,7 +2892,7 @@ local_pin_and_unpin_random_entries(H5F_t *file_ptr, int min_idx, int max_idx, in local_pin_random_entry(file_ptr, min_idx, max_idx); } - count = (HDrand() % (max_count - min_count)) + min_count; + count = (rand() % (max_count - min_count)) + min_count; assert(min_count <= count); assert(count <= max_count); @@ -2938,7 +2938,7 @@ local_pin_random_entry(H5F_t *file_ptr, int min_idx, int max_idx) assert(max_idx < virt_num_data_entries); do { - idx = (HDrand() % (max_idx - min_idx)) + min_idx; + idx = (rand() % (max_idx - min_idx)) + min_idx; assert(min_idx <= idx); assert(idx <= max_idx); } while (data[idx].global_pinned || data[idx].local_pinned); @@ -3055,7 +3055,7 @@ lock_and_unlock_random_entries(H5F_t *file_ptr, int min_idx, int max_idx, int mi assert(0 <= min_count); assert(min_count < max_count); - count = (HDrand() % (max_count - min_count)) + min_count; + count = (rand() % (max_count - min_count)) + min_count; assert(min_count <= count); assert(count <= max_count); @@ -3093,7 +3093,7 @@ lock_and_unlock_random_entry(H5F_t *file_ptr, int min_idx, int max_idx) assert(max_idx < NUM_DATA_ENTRIES); assert(max_idx < virt_num_data_entries); - idx = (HDrand() % (max_idx - min_idx)) + min_idx; + idx = (rand() % (max_idx - min_idx)) + min_idx; assert(min_idx <= idx); assert(idx <= max_idx); @@ -3933,7 +3933,7 @@ setup_rand(void) seed = predefined_seeds[world_mpi_rank]; fprintf(stdout, "%d:%s: predefined_seed = %d.\n", world_mpi_rank, __func__, seed); fflush(stdout); - HDsrand(seed); + srand(seed); } else { @@ -3950,7 +3950,7 @@ setup_rand(void) fprintf(stdout, "%d:%s: seed = %d.\n", world_mpi_rank, __func__, seed); fflush(stdout); } - HDsrand(seed); + srand(seed); } } diff --git a/testpar/t_pmulti_dset.c b/testpar/t_pmulti_dset.c index 4d8bc7707ec..c3c65c62479 100644 --- a/testpar/t_pmulti_dset.c +++ b/testpar/t_pmulti_dset.c @@ -267,7 +267,7 @@ test_pmdset(size_t niter, unsigned flags) for (i = 0; i < niter; i++) { /* Determine number of datasets */ ndsets = (flags & MDSET_FLAG_MLAYOUT) ? 3 - : (flags & MDSET_FLAG_MDSET) ? (size_t)((size_t)HDrandom() % max_dsets) + 1 + : (flags & MDSET_FLAG_MDSET) ? (size_t)((size_t)rand() % max_dsets) + 1 : 1; /* Create file */ @@ -280,16 +280,16 @@ test_pmdset(size_t niter, unsigned flags) (flags & MDSET_FLAG_CHUNK) || ((flags & MDSET_FLAG_MLAYOUT) && (j == 1 || j == 2)); /* Generate file dataspace */ - dset_dims[j][0] = (hsize_t)((HDrandom() % MAX_DSET_X) + 1); - dset_dims[j][1] = (hsize_t)((HDrandom() % MAX_DSET_Y) + 1); + dset_dims[j][0] = (hsize_t)((rand() % MAX_DSET_X) + 1); + dset_dims[j][1] = (hsize_t)((rand() % MAX_DSET_Y) + 1); if ((file_space_ids[j] = H5Screate_simple(2, dset_dims[j], use_chunk ? max_dims : NULL)) < 0) T_PMD_ERROR; /* Generate chunk if called for by configuration (multi layout uses chunked for datasets * 1 and 2) */ if (use_chunk) { - chunk_dims[0] = (hsize_t)((HDrandom() % MAX_CHUNK_X) + 1); - chunk_dims[1] = (hsize_t)((HDrandom() % MAX_CHUNK_Y) + 1); + chunk_dims[0] = (hsize_t)((rand() % MAX_CHUNK_X) + 1); + chunk_dims[1] = (hsize_t)((rand() % MAX_CHUNK_Y) + 1); if (H5Pset_chunk(dcpl_id[j], 2, chunk_dims) < 0) T_PMD_ERROR; } /* end if */ @@ -297,10 +297,10 @@ test_pmdset(size_t niter, unsigned flags) /* Create dataset */ /* If MDSET_FLAG_TCONV is set, use a different datatype with 50% probability, so * some datasets require type conversion and others do not */ - if ((dset_ids[j] = H5Dcreate2(file_id, dset_name[j], - (flags & MDSET_FLAG_TCONV && HDrandom() % 2) ? H5T_NATIVE_LONG - : H5T_NATIVE_UINT, - file_space_ids[j], H5P_DEFAULT, dcpl_id[j], H5P_DEFAULT)) < 0) + if ((dset_ids[j] = + H5Dcreate2(file_id, dset_name[j], + (flags & MDSET_FLAG_TCONV && rand() % 2) ? H5T_NATIVE_LONG : H5T_NATIVE_UINT, + file_space_ids[j], H5P_DEFAULT, dcpl_id[j], H5P_DEFAULT)) < 0) T_PMD_ERROR; } /* end for */ @@ -325,7 +325,7 @@ test_pmdset(size_t niter, unsigned flags) /* Perform read/write operations */ for (j = 0; j < OPS_PER_FILE; j++) { /* Decide whether to read or write */ - do_read = (bool)(HDrandom() % 2); + do_read = (bool)(rand() % 2); /* Barrier to ensure processes have finished the previous operation */ @@ -387,9 +387,9 @@ test_pmdset(size_t niter, unsigned flags) (int)((unsigned)max_dsets * MAX_DSET_X * MAX_DSET_Y) * ((int)l - (int)mpi_rank); /* Decide whether to do a hyperslab or point selection */ - if (HDrandom() % 2) { + if (rand() % 2) { /* Hyperslab */ - size_t nhs = (size_t)((HDrandom() % MAX_HS) + 1); /* Number of hyperslabs */ + size_t nhs = (size_t)((rand() % MAX_HS) + 1); /* Number of hyperslabs */ size_t max_hs_x = (MAX_HS_X <= dset_dims[k][0]) ? MAX_HS_X : dset_dims[k][0]; /* Determine maximum hyperslab size in X */ @@ -401,14 +401,14 @@ test_pmdset(size_t niter, unsigned flags) overlap = true; for (n = 0; overlap && (n < MAX_SEL_RETRIES); n++) { /* Generate hyperslab */ - count[m][0] = (hsize_t)(((hsize_t)HDrandom() % max_hs_x) + 1); - count[m][1] = (hsize_t)(((hsize_t)HDrandom() % max_hs_y) + 1); + count[m][0] = (hsize_t)(((hsize_t)rand() % max_hs_x) + 1); + count[m][1] = (hsize_t)(((hsize_t)rand() % max_hs_y) + 1); start[m][0] = (count[m][0] == dset_dims[k][0]) ? 0 - : (hsize_t)HDrandom() % (dset_dims[k][0] - count[m][0] + 1); + : (hsize_t)rand() % (dset_dims[k][0] - count[m][0] + 1); start[m][1] = (count[m][1] == dset_dims[k][1]) ? 0 - : (hsize_t)HDrandom() % (dset_dims[k][1] - count[m][1] + 1); + : (hsize_t)rand() % (dset_dims[k][1] - count[m][1] + 1); /* If writing, check for overlap with other processes */ overlap = false; @@ -460,8 +460,7 @@ test_pmdset(size_t niter, unsigned flags) } /* end if */ else { /* Point selection */ - size_t npoints = - (size_t)(((size_t)HDrandom() % MAX_POINTS) + 1); /* Number of points */ + size_t npoints = (size_t)(((size_t)rand() % MAX_POINTS) + 1); /* Number of points */ /* Reset dataset usage array if reading, since in this case we don't care * about overlapping selections between processes */ @@ -473,8 +472,8 @@ test_pmdset(size_t niter, unsigned flags) overlap = true; for (n = 0; overlap && (n < MAX_SEL_RETRIES); n++) { /* Generate point */ - points[2 * m] = (unsigned)((hsize_t)HDrandom() % dset_dims[k][0]); - points[(2 * m) + 1] = (unsigned)((hsize_t)HDrandom() % dset_dims[k][1]); + points[2 * m] = (unsigned)((hsize_t)rand() % dset_dims[k][0]); + points[(2 * m) + 1] = (unsigned)((hsize_t)rand() % dset_dims[k][1]); /* Check for overlap with other processes (write) or this process * (always) */ @@ -657,7 +656,7 @@ main(int argc, char *argv[]) /* Generate random number seed, if rank 0 */ if (MAINPROCESS) - seed = (unsigned)HDtime(NULL); + seed = (unsigned)time(NULL); /* Broadcast seed from rank 0 (other ranks will receive rank 0's seed) */ if (MPI_SUCCESS != MPI_Bcast(&seed, 1, MPI_UNSIGNED, 0, MPI_COMM_WORLD)) @@ -665,7 +664,7 @@ main(int argc, char *argv[]) /* Seed random number generator with shared seed (so all ranks generate the * same sequence) */ - HDsrandom(seed); + srand(seed); /* Fill dset_name array */ for (i = 0; i < MAX_DSETS; i++) { diff --git a/testpar/t_select_io_dset.c b/testpar/t_select_io_dset.c index 9d3f1205051..6382aed45b3 100644 --- a/testpar/t_select_io_dset.c +++ b/testpar/t_select_io_dset.c @@ -1588,7 +1588,7 @@ test_multi_dsets_no_bkg(hid_t fid, unsigned chunked, unsigned dtrans, unsigned s mwbuf ? "mwbuf" : "nomwbuf"); /* Flip a coin to see if we're doing type conversion */ - tconv = HDrandom() % 2; + tconv = rand() % 2; if (tconv) any_tconv = true; @@ -2079,7 +2079,7 @@ test_multi_dsets_cmpd_with_bkg(hid_t fid, unsigned chunked, unsigned select, uns } /* Case c */ - mm = HDrandom() % (int)ndsets; + mm = rand() % (int)ndsets; if (!mm) mm++; @@ -2720,7 +2720,7 @@ test_multi_dsets_conv_sel_empty(hid_t fid, unsigned chunked, unsigned dtrans, un } else { if ((dset_dids[i] = - H5Dcreate2(fid, dset_names[i], ((HDrandom() % 2) ? H5T_NATIVE_LLONG : H5T_NATIVE_SHORT), + H5Dcreate2(fid, dset_names[i], ((rand() % 2) ? H5T_NATIVE_LLONG : H5T_NATIVE_SHORT), file_sids[i], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) P_TEST_ERROR; } @@ -2790,7 +2790,7 @@ test_multi_dsets_conv_sel_empty(hid_t fid, unsigned chunked, unsigned dtrans, un * process 0: get 0 row; other processes: hyperslab */ - mm = HDrandom() % (int)ndsets; + mm = rand() % (int)ndsets; if (mm == 0) mm++; @@ -3169,7 +3169,7 @@ test_multi_dsets_all(int niter, hid_t fid, unsigned chunked, unsigned select, un if ((mem_sids[i] = H5Screate_simple(1, block, NULL)) < 0) P_TEST_ERROR; - mm = HDrandom() % (int)ndsets; + mm = rand() % (int)ndsets; if (mm == 0) { dset_types[i] = DSET_WITH_NO_CONV; snprintf(dset_names[i], sizeof(dset_names[i]), "multi_all_nconv_dset%d_%s_%s_%s", i, diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index a5c1aa5b4dc..bef90cf9061 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -2189,9 +2189,9 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi struct tm *tm; if (simple_output_g) - tm = HDgmtime(&(oinfo->mtime)); + tm = gmtime(&(oinfo->mtime)); else - tm = HDlocaltime(&(oinfo->mtime)); + tm = localtime(&(oinfo->mtime)); if (tm) { strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); h5tools_str_reset(&buffer); diff --git a/tools/test/perform/overhead.c b/tools/test/perform/overhead.c index ecdecb34d54..721124c05bb 100644 --- a/tools/test/perform/overhead.c +++ b/tools/test/perform/overhead.c @@ -206,7 +206,7 @@ test(fill_t fill_style, const double splits[], bool verbose, bool use_rdcc) hs_start[0] = k % 2 ? (k / 2) : (hsize_t)((hssize_t)cur_size[0] - (hssize_t)(k / 2)); break; case FILL_RANDOM: - for (j = HDrand() % (int)cur_size[0]; had[j]; j = (j + 1) % (int)cur_size[0]) + for (j = rand() % (int)cur_size[0]; had[j]; j = (j + 1) % (int)cur_size[0]) /*void*/; hs_start[0] = (hsize_t)j; had[j] = 1; diff --git a/tools/test/perform/zip_perf.c b/tools/test/perform/zip_perf.c index 76e455f4ab5..8f33a86bf42 100644 --- a/tools/test/perform/zip_perf.c +++ b/tools/test/perform/zip_perf.c @@ -337,7 +337,7 @@ fill_with_random_data(Bytef *src, uLongf src_len) fprintf(stdout, "Using random() for random data\n"); for (u = 0; u < src_len; ++u) - src[u] = (Bytef)(0xff & HDrandom()); + src[u] = (Bytef)(0xff & rand()); } if (compress_percent) {