File: sysdep.h

package info (click to toggle)
casacore 3.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 44,728 kB
  • sloc: cpp: 455,618; fortran: 16,301; ansic: 7,403; yacc: 4,547; lex: 2,327; sh: 1,679; python: 704; perl: 523; sed: 499; csh: 34; makefile: 24
file content (184 lines) | stat: -rw-r--r-- 5,900 bytes parent folder | download | duplicates (6)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
 *  History:
 *    pjt 31oct89 _trace_ added as defined() option, BUFALIGN 8.
 *    rjs 21feb90 Added alternate way of defining FORT_TRUE and FALSE
 *		  to improve XMP and Cray-2 compatibility. This change
 *		  care of Brian Glendenning.
 *    mjs  ??     Increased BUFSIZE to avoid apparent OS problem on "ral".
 *    rjs  8feb91 Convex definitions.
 *    mjs 18mar91 More Convex definitions.
 *    rjs 16apr91 Removed macros redefining memcpy as bcopy -- no longer
 *		  needed, and bcopy is slower on the Suns anyway.
 *    rjs 24jun91 Added memcmp define for the convex.
 *    rjs 18dec92 Added hpux. Various tidying.
 *    mjs 19feb93 Added mips.
 *     jm 07nov94 Added definition of Null and typedef of Void.  The
 *                Void typedef permits proper casting in both ANSI
 *                and non-ANSI archs.  Also added definition to permit
 *                the use of const in non-ANSI declarations.
 *     jm 17nov94 Changed the conditional definition around the typedef
 *                of Void because Sun defines __STDC__ even when it is
 *                zero!  Defined PROTOTYPE as 1 if __STDC__ is set to 1;
 *                otherwise it is undefined.  Also added ARGS definition
 *                to aide forward declartion prototyping.
 *    rjs 20nov94 Added "alpha" ifdef.
 *    rjs 19mar97 Add FORTRAN_LOGICAL define and check that miriad.h declarations
 *		  have not been done before doing them again.
 *    pjt 14jun01 use WORDS_BIGENDIAN to figure out the pack routines
 *                removed 'trace' clutter from the old multiflow
 *    pjt 24jun01 PPC/powerpc is a BIGENDIAN (linux) machine
 *    pjt 21jun02 MIR4
 *    pjt  4jan05 merged in the new ATNF HAS_STRERROR
 *    pjt  6feb07 kludge for darwin_intel
 *    cgk 20dec07 make HAS_STRERROR be HAVE_STRERROR per configure.ac
 */

#if !defined(MIR_SYSDEP_H)
#define MIR_SYSDEP_H

#include <sys/types.h>
#include <unistd.h>


#ifndef Null
#define Null '\0'
#endif

/*
 *  Void is typedef'd to the proper word depending on the level of
 *  ANSI conformance.  Also, if ANSI conforming, Const is defined
 *  to const; otherwise, Const is defined as a NULL statement.
 *
 *  PROTOTYPE is defined only if function prototypes are correctly
 *  understood.
 *
 *  ARGS defines a macro that aides in presenting prototypes.
 *  Use it as (double parentheses required):
 *    extern void keyput_c ARGS((const char *task, char *arg));
 */

#ifndef MIRIAD_TYPES_DEFINED
#define MIRIAD_TYPES_DEFINED 1
#ifdef __STDC__
#if (__STDC__ == 1)
typedef void Void;
#define Const const
#define PROTOTYPE 1
#define ARGS(s) s
#else
typedef char Void;
#define Const /* NULL */
#define ARGS(s) ()
#endif /* (__STDC__ == 1) */
#else
typedef char Void;
#define Const /* NULL */
#define ARGS(s) ()
#endif /* __STDC__ */
#if !defined(__cplusplus)
#define private static
#endif /* __cplusplus */
#endif /* MIRIAD_TYPES_DEFINED */

typedef int int2;
typedef long long int int8;

/************************************************************************/
/*									*/
/*			UNICOS definitions				*/
/*									*/
/************************************************************************/

#ifdef unicos
#include <fortran.h>
#define FORT_TRUE  _btol(1)
#define FORT_FALSE _btol(0)
#define FORT_LOGICAL(a) (_ltob((&(a))))
#define BUFDBUFF 0
#define BUFALIGN 8
#define BUFSIZE 16384
#define defined_params
#endif

/************************************************************************/
/*									*/
/*			UNIX definitions.				*/
/*									*/
/************************************************************************/

#ifndef defined_params
#if defined(convex) || defined(alpha) || defined(__alpha)
#  define FORT_TRUE  -1
#else
#  define FORT_TRUE 1
#endif

#define FORT_FALSE 0
#define FORT_LOGICAL(a) ((a) != FORT_FALSE)

#define BUFDBUFF 0
#define BUFALIGN 2
#define BUFSIZE 16384

/* Some machines have the "strerror" routine. Linux whinges significantly
   if you use the "old" way of doing effectively what strerror does. */

/* strerror is POSIX and should be supported under any POSIX.1 system */
/* Moving check for strerror into configure steps to define HAVE_STRERROR */
/* left old style build compatible check in bug.c */


/*  Short cut routines when no conversion is necessary. These are
    used for any IEEE floating point machine with FITS ordered bytes.	

    WORDS_BIGENDIAN is also defined though the 'autoconf' package
    and should appear in config.h if it's used (sun's, linuxppc, etc.)
    two routines, pack16_c() and unpack16_c() are actually defined
    in pack.c

 */


#ifndef WORDS_BIGENDIAN
# if defined (sun) || defined (convex) || defined (mips) || defined(sgi) || defined(hpux)
#  define WORDS_BIGENDIAN
# endif
# if defined(PPC) || defined(powerpc) || defined(darwin_ppc)
#  define WORDS_BIGENDIAN
# endif
#endif

#if defined(i386)
#undef WORDS_BIGENDIAN
#endif

#ifdef WORDS_BIGENDIAN 
#  define packr_c(a,b,c)    memcpy((b),(char *)(a),sizeof(float)*(c))
#  define unpackr_c(a,b,c)  memcpy((char *)(b),(a),sizeof(float)*(c))
#  define packd_c(a,b,c)    memcpy((b),(char *)(a),sizeof(double)*(c))
#  define unpackd_c(a,b,c)  memcpy((char *)(b),(a),sizeof(double)*(c))
#  define pack32_c(a,b,c)   memcpy((b),(char *)(a),sizeof(int)*(c))
#  define unpack32_c(a,b,c) memcpy((char *)(b),(a),sizeof(int)*(c))

void pack16_c(int *in, char *out, int n);
void unpack16_c(char *in, int *out, int n);

#else

#if 1
void pack16_c(int *in, char *out, int n);
void unpack16_c(char *in, int *out, int n);
void pack32_c(int *in, char *out, int n);
void unpack32_c(char *in, int *out, int n);
void pack64_c(int8 *in, char *out, int n);
void unpack64_c(char *in, int8 *out, int n);
void packr_c(float *in, char *out, int n);
void unpackr_c(char *in, float *out, int n);
void packd_c(double *in, char *out, int n);
void unpackd_c(char *in, double *out, int n);
#endif

#endif
#endif

#endif /* MIR_SYSDEP_H */