]> granicus.if.org Git - postgresql/blob - src/include/port/win32.h
Attached is a patch that fixes some trivial typos and alignment. Please
[postgresql] / src / include / port / win32.h
1 /* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.14 2004/01/26 22:51:56 momjian Exp $ */
2
3 /* undefine and redefine after #include */
4 #undef mkdir
5
6 #undef ERROR
7 #include <windows.h>
8 #undef near
9
10 /* Must be here to avoid conflicting with prototype in windows.h */
11 #define mkdir(a,b)      mkdir(a)
12
13
14 #define USES_WINSOCK
15 #define NOFILE            100
16
17 /* defines for dynamic linking on Win32 platform */
18 #if defined(__CYGWIN__) || defined(__MINGW32__)
19
20 #if __GNUC__ && ! defined (__declspec)
21 #error You need egcs 1.1 or newer for compiling!
22 #endif
23
24 #ifdef BUILDING_DLL
25 #define DLLIMPORT __declspec (dllexport)
26 #else                                                   /* not BUILDING_DLL */
27 #define DLLIMPORT __declspec (dllimport)
28 #endif
29
30 #elif defined(WIN32) && defined(_MSC_VER)               /* not CYGWIN or MingW */
31
32 #if defined(_DLL)
33 #define DLLIMPORT __declspec (dllexport)
34 #else                                                   /* not _DLL */
35 #define DLLIMPORT __declspec (dllimport)
36 #endif
37
38 #else                                                   /* not CYGWIN, not MSVC, not MingW */
39
40 #define DLLIMPORT
41 #endif
42
43 /*
44  *      IPC defines
45  */
46 #undef HAVE_UNION_SEMUN
47 #define HAVE_UNION_SEMUN 1
48
49 #define IPC_RMID 256
50 #define IPC_CREAT 512
51 #define IPC_EXCL 1024
52 #define IPC_PRIVATE 234564
53 #define IPC_NOWAIT      2048
54 #define IPC_STAT 4096
55
56 #define EACCESS 2048
57 #define EIDRM 4096
58
59 #define SETALL 8192
60 #define GETNCNT 16384
61 #define GETVAL 65536
62 #define SETVAL 131072
63 #define GETPID 262144
64
65 /*
66  *      Shared memory
67  */
68 struct shmid_ds
69 {
70         int                     dummy;
71         int                     shm_nattch;
72 };
73
74 int                     shmdt(const void *shmaddr);
75 void       *shmat(int memId, void *shmaddr, int flag);
76 int                     shmctl(int shmid, int flag, struct shmid_ds * dummy);
77 int                     shmget(int memKey, int size, int flag);
78
79
80 /*
81  *      Semaphores
82  */
83 union semun
84 {
85         int                     val;
86         struct semid_ds *buf;
87         unsigned short *array;
88 };
89
90 struct sembuf
91 {
92         int                     sem_flg;
93         int                     sem_op;
94         int                     sem_num;
95 };
96
97 int                     semctl(int semId, int semNum, int flag, union semun);
98 int                     semget(int semKey, int semNum, int flags);
99 int                     semop(int semId, struct sembuf * sops, int flag);
100
101 #define sleep(sec)      (Sleep(sec * 1000), /* no return value */ 0)
102
103 /* Some extra signals */
104 #define SIGHUP                          1
105 #define SIGQUIT                         3
106 #define SIGTRAP                         5
107 #define SIGABRT                         22      /* Set to match W32 value -- not UNIX
108                                                                  * value */
109 #define SIGKILL                         9
110 #define SIGPIPE                         13
111 #define SIGALRM                         14
112 #define SIGSTOP                         17
113 #define SIGCONT                         19
114 #define SIGCHLD                         20
115 #define SIGTTIN                         21
116 #define SIGTTOU                         22      /* Same as SIGABRT -- no problem, I hope */
117 #define SIGWINCH                        28
118 #define SIGUSR1                         30
119 #define SIGUSR2                         31
120
121 struct timezone
122 {
123         int                     tz_minuteswest; /* Minutes west of GMT.  */
124         int                     tz_dsttime;             /* Nonzero if DST is ever in effect.  */
125 };
126
127 /* FROM SRA */
128
129 /*
130  * Supplement to <sys/types.h>.
131  */
132 #define uid_t int
133 #define gid_t int
134 #define pid_t unsigned long
135 #define ssize_t int
136 #define mode_t int
137 #define key_t long
138 #define ushort unsigned short
139
140 /*
141  * Supplement to <sys/stat.h>.
142  */
143 #define lstat slat
144
145 #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
146 #define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
147
148 #define S_IRUSR _S_IREAD
149 #define S_IWUSR _S_IWRITE
150 #define S_IXUSR _S_IEXEC
151 #define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
152
153 /*
154  * Supplement to <errno.h>.
155  */
156 #include <errno.h>
157 #undef EAGAIN
158 #undef EINTR
159 #define EINTR WSAEINTR
160 #define EAGAIN WSAEWOULDBLOCK
161 #define EMSGSIZE WSAEMSGSIZE
162 #define EAFNOSUPPORT WSAEAFNOSUPPORT
163 #define EWOULDBLOCK WSAEWOULDBLOCK
164 #define ECONNRESET WSAECONNRESET
165 #define EINPROGRESS WSAEINPROGRESS