Eneboo - Documentación para desarrolladores
src/libpq/include/port/win32.h
Ir a la documentación de este archivo.
00001 /* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.49 2005/10/25 15:15:16 tgl Exp $ */
00002 
00003 /* undefine and redefine after #include */
00004 #undef mkdir
00005 
00006 #undef ERROR
00007 #include <windows.h>
00008 #include <winsock.h>
00009 #include <process.h>
00010 #include <signal.h>
00011 #include <errno.h>
00012 
00013 #undef near
00014 
00015 /* Must be here to avoid conflicting with prototype in windows.h */
00016 #define mkdir(a,b)      mkdir(a)
00017 
00018 
00019 #define HAVE_FSYNC_WRITETHROUGH
00020 #define HAVE_FSYNC_WRITETHROUGH_ONLY
00021 #define ftruncate(a,b)  chsize(a,b)
00022 /*
00023  *      Even though we don't support 'fsync' as a wal_sync_method,
00024  *      we do fsync() a few other places where _commit() is just fine.
00025  */
00026 #define fsync(fd) _commit(fd)
00027 
00028 #define USES_WINSOCK
00029 
00030 /* defines for dynamic linking on Win32 platform */
00031 #if defined(__MINGW32__) || defined(__CYGWIN__)
00032 
00033 #if __GNUC__ && ! defined (__declspec)
00034 #error You need egcs 1.1 or newer for compiling!
00035 #endif
00036 
00037 #ifdef BUILDING_DLL
00038 #define DLLIMPORT __declspec (dllexport)
00039 #else                                                   /* not BUILDING_DLL */
00040 #define DLLIMPORT __declspec (dllimport)
00041 #endif
00042 #elif defined(WIN32_CLIENT_ONLY)
00043 
00044 #if defined(_DLL)
00045 #define DLLIMPORT __declspec (dllexport)
00046 #else                                                   /* not _DLL */
00047 #define DLLIMPORT __declspec (dllimport)
00048 #endif
00049 #else                                                   /* not CYGWIN, not MSVC, not MingW */
00050 
00051 #define DLLIMPORT
00052 #endif
00053 
00054 /*
00055  *      IPC defines
00056  */
00057 #undef HAVE_UNION_SEMUN
00058 #define HAVE_UNION_SEMUN 1
00059 
00060 #define IPC_RMID 256
00061 #define IPC_CREAT 512
00062 #define IPC_EXCL 1024
00063 #define IPC_PRIVATE 234564
00064 #define IPC_NOWAIT      2048
00065 #define IPC_STAT 4096
00066 
00067 #define EACCESS 2048
00068 #define EIDRM 4096
00069 
00070 #define SETALL 8192
00071 #define GETNCNT 16384
00072 #define GETVAL 65536
00073 #define SETVAL 131072
00074 #define GETPID 262144
00075 
00076 /*
00077  *      Shared memory
00078  */
00079 struct shmid_ds
00080 {
00081         int                     dummy;
00082         int                     shm_nattch;
00083 };
00084 
00085 int                     shmdt(const void *shmaddr);
00086 void       *shmat(int memId, void *shmaddr, int flag);
00087 int                     shmctl(int shmid, int flag, struct shmid_ds * dummy);
00088 int                     shmget(int memKey, int size, int flag);
00089 
00090 
00091 /*
00092  *      Semaphores
00093  */
00094 union semun
00095 {
00096         int                     val;
00097         struct semid_ds *buf;
00098         unsigned short *array;
00099 };
00100 
00101 struct sembuf
00102 {
00103         int                     sem_flg;
00104         int                     sem_op;
00105         int                     sem_num;
00106 };
00107 
00108 int                     semctl(int semId, int semNum, int flag, union semun);
00109 int                     semget(int semKey, int semNum, int flags);
00110 int                     semop(int semId, struct sembuf * sops, int flag);
00111 
00112 
00113 /*
00114  * Signal stuff
00115  */
00116 #define WEXITSTATUS(w)  (((w) >> 8) & 0xff)
00117 #define WIFEXITED(w)    (((w) & 0xff) == 0)
00118 #define WIFSIGNALED(w)  (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
00119 #define WTERMSIG(w)             ((w) & 0x7f)
00120 
00121 #define sigmask(sig) ( 1 << ((sig)-1) )
00122 
00123 /* Signal function return values */
00124 #undef SIG_DFL
00125 #undef SIG_ERR
00126 #undef SIG_IGN
00127 #define SIG_DFL ((pqsigfunc)0)
00128 #define SIG_ERR ((pqsigfunc)-1)
00129 #define SIG_IGN ((pqsigfunc)1)
00130 
00131 /* Some extra signals */
00132 #define SIGHUP                          1
00133 #define SIGQUIT                         3
00134 #define SIGTRAP                         5
00135 #define SIGABRT                         22      /* Set to match W32 value -- not UNIX value */
00136 #define SIGKILL                         9
00137 #define SIGPIPE                         13
00138 #define SIGALRM                         14
00139 #define SIGSTOP                         17
00140 #define SIGTSTP                         18
00141 #define SIGCONT                         19
00142 #define SIGCHLD                         20
00143 #define SIGTTIN                         21
00144 #define SIGTTOU                         22      /* Same as SIGABRT -- no problem, I hope */
00145 #define SIGWINCH                        28
00146 #define SIGUSR1                         30
00147 #define SIGUSR2                         31
00148 
00149 struct timezone
00150 {
00151         int                     tz_minuteswest; /* Minutes west of GMT.  */
00152         int                     tz_dsttime;             /* Nonzero if DST is ever in effect.  */
00153 };
00154 
00155 /* for setitimer in backend/port/win32/timer.c */
00156 #define ITIMER_REAL 0
00157 struct itimerval
00158 {
00159         struct timeval it_interval;
00160         struct timeval it_value;
00161 };
00162 int                     setitimer(int which, const struct itimerval * value, struct itimerval * ovalue);
00163 
00164 
00165 /*
00166  * Supplement to <sys/types.h>.
00167  *
00168  * Perl already has conflicting defines for uid_t and gid_t.
00169  */
00170 #ifndef PLPERL_HAVE_UID_GID
00171 typedef int uid_t;
00172 typedef int gid_t;
00173 #else
00174 /* These are redefined by perl. */
00175 #define uid_t int
00176 #define gid_t int
00177 #endif
00178 typedef long key_t;
00179 
00180 #ifdef WIN32_CLIENT_ONLY
00181 typedef int pid_t;
00182 #endif
00183 
00184 /*
00185  * Supplement to <sys/stat.h>.
00186  */
00187 #define lstat(path, sb) stat((path), (sb))
00188 
00189 /*
00190  * Supplement to <fcntl.h>.
00191  * This is the same value as _O_NOINHERIT in the MS header file. This is
00192  * to ensure that we don't collide with a future definition. It means
00193  * we cannot use _O_NOINHERIT ourselves.
00194  */
00195 #define O_DSYNC 0x0080
00196 
00197 /*
00198  * Supplement to <errno.h>.
00199  */
00200 #undef EAGAIN
00201 #undef EINTR
00202 #define EINTR WSAEINTR
00203 #define EAGAIN WSAEWOULDBLOCK
00204 #define EMSGSIZE WSAEMSGSIZE
00205 #define EAFNOSUPPORT WSAEAFNOSUPPORT
00206 #define EWOULDBLOCK WSAEWOULDBLOCK
00207 #define ECONNRESET WSAECONNRESET
00208 #define EINPROGRESS WSAEINPROGRESS
00209 #define ENOBUFS WSAENOBUFS
00210 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
00211 #define ECONNREFUSED WSAECONNREFUSED
00212 #define EBADFD WSAENOTSOCK
00213 #define EOPNOTSUPP WSAEOPNOTSUPP
00214 
00215 
00216 /* In backend/port/win32/signal.c */
00217 extern DLLIMPORT volatile int pg_signal_queue;
00218 extern DLLIMPORT int pg_signal_mask;
00219 extern HANDLE pgwin32_signal_event;
00220 extern HANDLE pgwin32_initial_signal_pipe;
00221 
00222 #define UNBLOCKED_SIGNAL_QUEUE()        (pg_signal_queue & ~pg_signal_mask)
00223 
00224 
00225 void            pgwin32_signal_initialize(void);
00226 HANDLE          pgwin32_create_signal_listener(pid_t pid);
00227 void            pgwin32_dispatch_queued_signals(void);
00228 void            pg_queue_signal(int signum);
00229 
00230 #ifndef FRONTEND
00231 #define pg_usleep(t) pgwin32_backend_usleep(t)
00232 void            pgwin32_backend_usleep(long microsec);
00233 #endif
00234 
00235 /* In backend/port/win32/socket.c */
00236 #ifndef FRONTEND
00237 #define socket(af, type, protocol) pgwin32_socket(af, type, protocol)
00238 #define accept(s, addr, addrlen) pgwin32_accept(s, addr, addrlen)
00239 #define connect(s, name, namelen) pgwin32_connect(s, name, namelen)
00240 #define select(n, r, w, e, timeout) pgwin32_select(n, r, w, e, timeout)
00241 #define recv(s, buf, len, flags) pgwin32_recv(s, buf, len, flags)
00242 #define send(s, buf, len, flags) pgwin32_send(s, buf, len, flags)
00243 
00244 SOCKET          pgwin32_socket(int af, int type, int protocol);
00245 SOCKET          pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen);
00246 int                     pgwin32_connect(SOCKET s, const struct sockaddr * name, int namelen);
00247 int                     pgwin32_select(int nfds, fd_set *readfs, fd_set *writefds, fd_set *exceptfds, const struct timeval * timeout);
00248 int                     pgwin32_recv(SOCKET s, char *buf, int len, int flags);
00249 int                     pgwin32_send(SOCKET s, char *buf, int len, int flags);
00250 
00251 const char *pgwin32_socket_strerror(int err);
00252 int                     pgwin32_waitforsinglesocket(SOCKET s, int what);
00253 
00254 /* in backend/port/win32/security.c */
00255 extern int      pgwin32_is_admin(void);
00256 extern int      pgwin32_is_service(void);
00257 #endif
00258 
00259 /* in backend/port/win32/error.c */
00260 extern void _dosmaperr(unsigned long);
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'