Permalink
Browse files

- windows support

  • Loading branch information...
1 parent 33a1a98 commit 3c66e8ba02eaa96b59e794c6d56817d1a2e40b01 @pierrejoye pierrejoye committed Dec 31, 2010
Showing with 86 additions and 28 deletions.
  1. +10 −0 config.w32
  2. +7 −1 hash.h
  3. +7 −5 hash_function.c
  4. +5 −3 hash_function.h
  5. +3 −0 hash_si.c
  6. +24 −0 ig_win32.h
  7. +25 −16 igbinary.c
  8. +5 −3 igbinary.h
View
@@ -0,0 +1,10 @@
+// $Id$
+// vim:ft=javascript
+
+ARG_ENABLE("igbinary", "whether to enable igbinary support", "no");
+
+if (PHP_IGBINARY == "yes") {
+ EXTENSION("igbinary", "igbinary.c hash_si.c hash_function.c");
+ AC_DEFINE('HAVE_IGBINARY', 1, 'Have igbinary support', false);
+ ADD_EXTENSION_DEP('igbinary', 'session');
+}
View
@@ -8,7 +8,13 @@
#define HASH_H
#include <assert.h>
-#include <stdint.h>
+
+#ifdef PHP_WIN32
+# include "ig_win32.h"
+#else
+# include <stdint.h> /* defines uint32_t etc */
+#endif
+
#include <stddef.h>
/** Key/value pair of hash_si.
View
@@ -2,12 +2,14 @@
-------------------------------------------------------------------------------
lookup3.c, by Bob Jenkins, May 2006, Public Domain.
*/
-
-#include <sys/param.h> /* attempt to define endianness */
-#ifdef linux
-# include <endian.h> /* attempt to define endianness */
+#ifdef PHP_WIN32
+# include "ig_win32.h"
+#else
+# include <sys/param.h> /* attempt to define endianness */
+# ifdef linux
+# include <endian.h> /* attempt to define endianness */
+# endif
#endif
-
#include "hash_function.h"
#define hashsize(n) ((uint32_t)1<<(n))
View
@@ -6,9 +6,11 @@
#ifndef HASH_FUNCTION_H
#define HASH_FUNCTION_H
-
-#include <stdint.h> /* defines uint32_t etc */
-
+#ifdef PHP_WIN32
+# include "ig_win32.h"
+#else
+# include <stdint.h> /* defines uint32_t etc */
+#endif
/**
* Hash function
*
View
@@ -3,6 +3,9 @@
*
* $Id: hash_si.c,v 1.5 2008/07/01 17:02:18 phadej Exp $
*/
+#ifdef PHP_WIN32
+# include "ig_win32.h"
+#endif
#include <stdio.h>
#include <stdlib.h>
View
@@ -0,0 +1,24 @@
+#ifndef _IG_WIN32_H
+#define _IG_WIN32_H
+
+#if PHP_WIN32
+# include "win32/php_stdint.h"
+# ifndef inline
+# define inline __inline
+# endif
+
+# ifndef __cplusplus
+# if !0
+typedef enum { false = 0, true = 1 } _Bool;
+# endif
+# else
+typedef bool _Bool;
+# endif
+# define bool _Bool
+
+# define false 0
+# define true 1
+# define __bool_true_false_are_defined 1
+#endif
+
+#endif
View
@@ -8,6 +8,10 @@
#include "config.h"
#endif
+#ifdef PHP_WIN32
+# include "ig_win32.h"
+#endif
+
#include "php.h"
#include "php_ini.h"
#include "zend_dynamic_array.h"
@@ -21,11 +25,14 @@
#include <assert.h>
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
+#ifndef PHP_WIN32
+# include <inttypes.h>
+# include <stdbool.h>
+# include <stdint.h>
+#endif
+
+#include <stddef.h>
#include "hash.h"
/** Session serializer function prototypes. */
@@ -326,13 +333,13 @@ int igbinary_unserialize(const uint8_t *buf, size_t buf_len, zval **z TSRMLS_DC)
/* }}} */
/* {{{ proto string igbinary_unserialize(mixed value) */
PHP_FUNCTION(igbinary_unserialize) {
+ char *string;
+ int string_len;
+
(void) return_value_ptr;
(void) this_ptr;
(void) return_value_used;
- char *string;
- int string_len;
-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) {
RETURN_NULL();
}
@@ -348,12 +355,13 @@ PHP_FUNCTION(igbinary_unserialize) {
/* }}} */
/* {{{ proto mixed igbinary_serialize(string value) */
PHP_FUNCTION(igbinary_serialize) {
+ zval *z;
+ struct igbinary_serialize_data igsd;
+
(void) return_value_ptr;
(void) this_ptr;
(void) return_value_used;
- zval *z;
- struct igbinary_serialize_data igsd;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &z) == FAILURE) {
RETURN_NULL();
@@ -642,13 +650,13 @@ inline static int igbinary_serialize_long(struct igbinary_serialize_data *igsd,
/* {{{ igbinary_serialize_double */
/** Serializes double. */
inline static int igbinary_serialize_double(struct igbinary_serialize_data *igsd, double d TSRMLS_DC) {
- igbinary_serialize8(igsd, igbinary_type_double TSRMLS_CC);
-
union {
double d;
uint64_t u;
} u;
+ igbinary_serialize8(igsd, igbinary_type_double TSRMLS_CC);
+
u.d = d;
igbinary_serialize64(igsd, u.u TSRMLS_CC);
@@ -1331,17 +1339,18 @@ inline static int igbinary_unserialize_long(struct igbinary_unserialize_data *ig
/* {{{ igbinary_unserialize_double */
/** Unserializes double. */
inline static int igbinary_unserialize_double(struct igbinary_unserialize_data *igsd, enum igbinary_type t, double *ret TSRMLS_DC) {
+ union {
+ double d;
+ uint64_t u;
+ } u;
+
(void) t;
if (igsd->buffer_offset + 8 > igsd->buffer_size) {
zend_error(E_WARNING, "igbinary_unserialize_double: end-of-data");
return 1;
}
- union {
- double d;
- uint64_t u;
- } u;
u.u = igbinary_unserialize64(igsd TSRMLS_CC);
@@ -1498,7 +1507,7 @@ inline static int igbinary_unserialize_array(struct igbinary_unserialize_data *i
// n cannot be larger than the number of minimum "objects" in the array
if (n > igsd->buffer_size - igsd->buffer_offset) {
- zend_error(E_WARNING, "%s: data size %zu smaller that requested array length %zu.", __func__, igsd->buffer_size - igsd->buffer_offset, n);
+ zend_error(E_WARNING, "%s: data size %zu smaller that requested array length %zu.", "igbinary_unserialize_array", igsd->buffer_size - igsd->buffer_offset, n);
return 1;
}
View
@@ -6,9 +6,11 @@
#ifndef IGBINARY_H
#define IGBINARY_H
-
-#include <stdint.h>
-
+#ifdef PHP_WIN32
+# include "ig_win32.h"
+#else
+# include <stdint.h>
+#endif
#include "php.h"
#define IGBINARY_VERSION "1.0.2"

0 comments on commit 3c66e8b

Please sign in to comment.