netcdf-c/libdispatch/ncrandom.c
Dennis Heimbigner 69ed78e7d7 Convert the ENABLE_XXX options to NETCDF_ENABLE_XXX options
# Primary Change
In order to conform to the cmake overhaul, occurrences of
ENABLE_XXX options in the nczarr code have been changed to
NETCDF_ENABLE_XXX.

# Misc. Other changes
* Fix use of rand_s in libdispatch/ncrandom.c
* Fix some bugs in the mingw gitub action.
* Fix signature bug in libncpoco/cp_win32.c
* Make some NCZarr fixes to config.h.cmake.in
2024-05-11 16:23:40 -06:00

35 lines
741 B
C

/*
* Copyright 2018, University Corporation for Atmospheric Research
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#if defined(_WIN32) || defined(_MSC_VER)
extern errno_t rand_s(unsigned int *randomValue);
#endif
/* Support platform independent generation of 32-bit unsigned int random numbers */
int
main() {
unsigned int urnd = 0; /* range 0..2147483647 */
#if defined(_WIN32) || defined(_MSC_VER)
(void)rand_s(&urnd);
#else
long rnd;
rnd = random();
urnd = (unsigned)(rnd & 0xffffffff);
#endif
printf("%u",urnd);
exit(0);
}