]> granicus.if.org Git - php/commitdiff
Allow compilation on Win32.
authorFrank M. Kromann <fmk@php.net>
Wed, 9 Jun 2004 19:27:36 +0000 (19:27 +0000)
committerFrank M. Kromann <fmk@php.net>
Wed, 9 Jun 2004 19:27:36 +0000 (19:27 +0000)
Need to implement a few Windows specific functions.

ext/dio/config.w32 [new file with mode: 0644]
ext/dio/dio.c

diff --git a/ext/dio/config.w32 b/ext/dio/config.w32
new file mode 100644 (file)
index 0000000..74f0871
--- /dev/null
@@ -0,0 +1,9 @@
+// $Id$
+// vim:ft=javascript
+
+ARG_ENABLE("dio", "Enable the direct I/O support", "no");
+
+if (PHP_DIO != "no") {
+       EXTENSION("dio", "dio.c");
+       AC_DEFINE('HAVE_DIO', 1, 'dio support');
+}
index fcd171c1c8cd1d0ccba8925eb1d65aed1aee62bc..5f965766abefd872413fbb3b8490424787558378 100644 (file)
 
 #include <sys/stat.h>
 #include <sys/types.h>
+
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
+
 #include <fcntl.h>
+#ifndef PHP_WIN32
 #include <termios.h>
+#endif
 
 /* e.g. IRIX does not have CRTSCTS */
 #ifndef CRTSCTS
@@ -45,14 +51,20 @@ static int le_fd;
 
 function_entry dio_functions[] = {
        PHP_FE(dio_open,      NULL)
+#ifndef PHP_WIN32
        PHP_FE(dio_truncate,  NULL)
+#endif
        PHP_FE(dio_stat,      NULL)
        PHP_FE(dio_seek,      NULL)
+#ifndef PHP_WIN32
        PHP_FE(dio_fcntl,     NULL)
+#endif
        PHP_FE(dio_read,      NULL)
        PHP_FE(dio_write,     NULL)
        PHP_FE(dio_close,     NULL)
+#ifndef PHP_WIN32
        PHP_FE(dio_tcsetattr,     NULL)
+#endif
        {NULL, NULL, NULL}
 };
 
@@ -94,15 +106,22 @@ PHP_MINIT_FUNCTION(dio)
        RDIOC(O_EXCL);
        RDIOC(O_TRUNC);
        RDIOC(O_APPEND);
+#ifdef O_NONBLOCK
        RDIOC(O_NONBLOCK);
+#endif
+#ifdef O_NDELAY
        RDIOC(O_NDELAY);
+#endif
 #ifdef O_SYNC
        RDIOC(O_SYNC);
 #endif
 #ifdef O_ASYNC
        RDIOC(O_ASYNC);
 #endif
+#ifdef O_NOCTTY
        RDIOC(O_NOCTTY);
+#endif
+#ifndef PHP_WIN32
        RDIOC(S_IRWXU);
        RDIOC(S_IRUSR);
        RDIOC(S_IWUSR);
@@ -127,6 +146,7 @@ PHP_MINIT_FUNCTION(dio)
        RDIOC(F_UNLCK);
        RDIOC(F_RDLCK);
        RDIOC(F_WRLCK);
+#endif
        
        return SUCCESS;
 }
@@ -235,6 +255,7 @@ PHP_FUNCTION(dio_write)
 }
 /* }}} */
 
+#ifndef PHP_WIN32
 /* {{{ proto bool dio_truncate(resource fd, int offset)
    Truncate file descriptor fd to offset bytes */
 PHP_FUNCTION(dio_truncate)
@@ -257,6 +278,7 @@ PHP_FUNCTION(dio_truncate)
        RETURN_TRUE;
 }
 /* }}} */
+#endif
 
 #define ADD_FIELD(f, v) add_assoc_long_ex(return_value, (f), sizeof(f), v);
 
@@ -288,8 +310,10 @@ PHP_FUNCTION(dio_stat)
        ADD_FIELD("gid", s.st_gid);
        ADD_FIELD("device_type", s.st_rdev);
        ADD_FIELD("size", s.st_size);
+#ifndef PHP_WIN32
        ADD_FIELD("block_size", s.st_blksize);
        ADD_FIELD("blocks", s.st_blocks);
+#endif
        ADD_FIELD("atime", s.st_atime);
        ADD_FIELD("mtime", s.st_mtime);
        ADD_FIELD("ctime", s.st_ctime);
@@ -315,6 +339,7 @@ PHP_FUNCTION(dio_seek)
 }
 /* }}} */
 
+#ifndef PHP_WIN32
 /* {{{ proto mixed dio_fcntl(resource fd, int cmd[, mixed arg])
    Perform a c library fcntl on fd */
 PHP_FUNCTION(dio_fcntl)
@@ -415,7 +440,9 @@ PHP_FUNCTION(dio_fcntl)
        }
 }
 /* }}} */
+#endif
 
+#ifndef PHP_WIN32
 /* {{{ proto mixed dio_tcsetattr(resource fd,  array args )
    Perform a c library tcsetattr on fd */
 PHP_FUNCTION(dio_tcsetattr)
@@ -576,6 +603,7 @@ PHP_FUNCTION(dio_tcsetattr)
        RETURN_TRUE;
 }
 /* }}} */
+#endif
 
 /* {{{ proto void dio_close(resource fd)
    Close the file descriptor given by fd */