]> granicus.if.org Git - postgresql/blob - src/include/postgres.h
This patch should enable 6.5 to build on Motorola 68000 architecture.
[postgresql] / src / include / postgres.h
1 /*-------------------------------------------------------------------------
2  *
3  * postgres.h
4  *        definition of (and support for) postgres system types.
5  * this file is included by almost every .c in the system
6  *
7  * Copyright (c) 1995, Regents of the University of California
8  *
9  * $Id: postgres.h,v 1.23 1999/06/10 22:59:22 momjian Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 /*
14  *       NOTES
15  *              this file will eventually contain the definitions for the
16  *              following (and perhaps other) system types:
17  *
18  *                              int2       int4           float4           float8
19  *                              Oid                regproc        RegProcedure
20  *                              aclitem
21  *                              struct varlena
22  *                              int28     oid8
23  *                              bytea      text
24  *                              NameData   Name
25  *
26  *       TABLE OF CONTENTS
27  *              1)              simple type definitions
28  *              2)              varlena and array types
29  *              3)              TransactionId and CommandId
30  *              4)              genbki macros used by catalog/pg_xxx.h files
31  *              5)              random CSIGNBIT, MAXPGPATH, STATUS macros
32  *
33  * ----------------------------------------------------------------
34  */
35 #ifndef POSTGRES_H
36 #define POSTGRES_H
37
38 #include "postgres_ext.h"
39 #ifndef WIN32
40 #include "config.h"
41 #endif
42 #include "c.h"
43 #include "utils/elog.h"
44 #include "utils/palloc.h"
45
46 /* ----------------------------------------------------------------
47  *                              Section 1:      simple type definitions
48  * ----------------------------------------------------------------
49  */
50
51 typedef int16 int2;
52 typedef int32 int4;
53 typedef float float4;
54 typedef double float8;
55
56 typedef int4 aclitem;
57
58 #define InvalidOid              0
59 #define OidIsValid(objectId)  ((bool) (objectId != InvalidOid))
60
61 /* unfortunately, both regproc and RegProcedure are used */
62 typedef Oid regproc;
63 typedef Oid RegProcedure;
64
65 /* ptr to func returning (char *) */
66 #if defined(__mc68000__) && defined(__ELF__)
67 /* The m68k SVR4 ABI defines that pointers are returned in %a0 instead of
68  * %d0. So if a function pointer is declared to return a pointer, the
69  * compiler may look only into %a0, but if the called function was declared
70  * to return return an integer type, it puts its value only into %d0. So the
71  * caller doesn't pink up the correct return value. The solution is to
72  * declare the function pointer to return int, so the compiler picks up the
73  * return value from %d0. (Functions returning pointers put their value
74  * *additionally* into %d0 for compability.) The price is that there are
75  * some warnings about int->pointer conversions...
76  */
77 typedef int32 ((*func_ptr) ());
78 #else 
79 typedef char *((*func_ptr) ());
80 #endif
81
82
83 #define RegProcedureIsValid(p)  OidIsValid(p)
84
85 /* ----------------------------------------------------------------
86  *                              Section 2:      variable length and array types
87  * ----------------------------------------------------------------
88  */
89 /* ----------------
90  *              struct varlena
91  * ----------------
92  */
93 struct varlena
94 {
95         int32           vl_len;
96         char            vl_dat[1];
97 };
98
99 #define VARSIZE(PTR)    (((struct varlena *)(PTR))->vl_len)
100 #define VARDATA(PTR)    (((struct varlena *)(PTR))->vl_dat)
101 #define VARHDRSZ                sizeof(int32)
102
103 typedef struct varlena bytea;
104 typedef struct varlena text;
105
106 typedef int2 int28[8];
107 typedef Oid oid8[8];
108
109 /* We want NameData to have length NAMEDATALEN and int alignment,
110  * because that's how the data type 'name' is defined in pg_type.
111  * Use a union to make sure the compiler agrees.
112  */
113 typedef union nameData
114 {
115         char            data[NAMEDATALEN];
116         int                     alignmentDummy;
117 } NameData;
118 typedef NameData *Name;
119
120 /* ----------------------------------------------------------------
121  *                              Section 3: TransactionId and CommandId
122  * ----------------------------------------------------------------
123  */
124
125 typedef uint32 TransactionId;
126
127 #define InvalidTransactionId    0
128 typedef uint32 CommandId;
129
130 #define FirstCommandId  0
131
132 /* ----------------------------------------------------------------
133  *                              Section 4: genbki macros used by the
134  *                                                 catalog/pg_xxx.h files
135  * ----------------------------------------------------------------
136  */
137 #define CATALOG(x) \
138         typedef struct CppConcat(FormData_,x)
139
140 #define DATA(x) extern int errno
141 #define DESCR(x) extern int errno
142 #define DECLARE_INDEX(x) extern int errno
143
144 #define BUILD_INDICES
145 #define BOOTSTRAP
146
147 #define BKI_BEGIN
148 #define BKI_END
149
150 /* ----------------------------------------------------------------
151  *                              Section 5:      random stuff
152  *                                                      CSIGNBIT, MAXPGPATH, STATUS...
153  * ----------------------------------------------------------------
154  */
155
156 /* msb for int/unsigned */
157 #define ISIGNBIT (0x80000000)
158 #define WSIGNBIT (0x8000)
159
160 /* msb for char */
161 #define CSIGNBIT (0x80)
162
163 /* ----------------
164  *              global variables which should probably go someplace else.
165  * ----------------
166  */
167 #define MAXPGPATH               128
168 #define MAX_QUERY_SIZE  (BLCKSZ*2)
169
170 #define STATUS_OK                               (0)
171 #define STATUS_ERROR                    (-1)
172 #define STATUS_NOT_FOUND                (-2)
173 #define STATUS_INVALID                  (-3)
174 #define STATUS_UNCATALOGUED             (-4)
175 #define STATUS_REPLACED                 (-5)
176 #define STATUS_NOT_DONE                 (-6)
177 #define STATUS_BAD_PACKET               (-7)
178 #define STATUS_FOUND                    (1)
179
180 /* ---------------
181  * Cyrillic on the fly charsets recode
182  * ---------------
183  */
184 #ifdef CYR_RECODE
185 void            SetCharSet();
186
187 #endif   /* CYR_RECODE */
188
189 #endif   /* POSTGRES_H */