-
Notifications
You must be signed in to change notification settings - Fork 23
/
machi_c.c
72 lines (66 loc) · 1.8 KB
/
machi_c.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#if defined(SGI)
/*
--- Fortran-callable routine ZUNDER that sets the bit to specify
--- that underflows are flushed to zero in hardware on SGI R10000.
--- See man handle_sigfpes
--- Alan J. Wallcraft, NRL, October 1997.
*/
#include <sys/fpu.h>
void zunder_()
{
union fpc_csr n;
n.fc_word = get_fpc_csr();
n.fc_struct.flush = 1;
set_fpc_csr(n.fc_word);
}
#endif /* SGI */
#if defined(AIX)
/*
--- Fortran-callable function WTIME that returns the wall time in seconds.
--- Probably not thread-safe, only for Power-PC systems.
--- Alan J. Wallcraft, NRL, May 2001.
--- Based on notes by Bob Walkup (10x faster than MPI_WTIME).
*/
#include <sys/time.h>
#include <sys/systemcfg.h>
double wtime(void)
{
struct timebasestruct TB;
static int first_call;
static double tb_factor;
double tb_top,tb_bot;
if (first_call == 0) {
first_call = 1;
tb_top = (double) _system_configuration.Xint;
tb_bot = (double) _system_configuration.Xfrac;
tb_factor = tb_top/tb_bot;
}
read_real_time(&TB, TIMEBASE_SZ);
return ( tb_factor * ( 4.294967296*((double) TB.tb_high) + 1.0e-9*((double) TB.tb_low) ) );
}
#endif /* AIX */
#if defined(ENDIAN_IO)
/*
--- Fortran-callable routine ZAIO_ENDIAN to swap the endian-ness of an array
--- Brent Anderson, ASC MSRC, July 2007.
*/
#include <inttypes.h>
void zaio_endian_(uint32_t *, uint32_t *);
#define swap4bytes(data) \
( (((data) >> 24) & 0x000000FF) | \
(((data) >> 8) & 0x0000FF00) | \
(((data) << 8) & 0x00FF0000) | \
(((data) << 24) & 0xFF000000) )
/** Swaps the byte-order in a 32-bit word from
big- to little-endianness or vice-versa. */
void zaio_endian_(uint32_t aa[], uint32_t *nn) {
uint32_t ii;
for( ii=0; ii<*nn; ii++ ) {
aa[ii] = swap4bytes ( aa[ii] );
}
return;
}
#endif /* ENDIAN_IO */
void machine_c()
{
}