Skip to content

Commit 51a7dae

Browse files
committedSep 20, 2013
almost trivial fixes to get it worky on windows
1 parent d18eb66 commit 51a7dae

9 files changed

+52
-21
lines changed
 

‎crypto/crypto_scrypt-nosse.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@
3333
#endif
3434

3535
#include <errno.h>
36-
#include <stdint.h>
36+
#ifdef PHP_WIN32
37+
# include "win32/php_stdint.h"
38+
#else
39+
# include <stdint.h>
40+
#endif
3741
#include <stdlib.h>
3842
#include <string.h>
3943

‎crypto/crypto_scrypt.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929
#ifndef _CRYPTO_SCRYPT_H_
3030
#define _CRYPTO_SCRYPT_H_
3131

32-
#include <stdint.h>
32+
#ifdef PHP_WIN32
33+
# include "win32/php_stdint.h"
34+
#else
35+
# include <stdint.h>
36+
#endif
3337

3438
/**
3539
* crypto_scrypt(passwd, passwdlen, salt, saltlen, N, r, p, buf, buflen):

‎crypto/params.c

+20-5
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,19 @@
2828
*/
2929

3030
#include <stddef.h>
31-
#include <stdint.h>
32-
#include <unistd.h>
31+
#ifdef PHP_WIN32
32+
# include "win32/time.h"
33+
# include "win32/php_stdint.h"
34+
#else
35+
# include <stdint.h>
36+
# include <unistd.h>
37+
#endif
3338
#include <errno.h>
3439
#include <time.h>
35-
#include <sys/time.h>
36-
#include <sys/resource.h>
40+
#ifndef PHP_WIN32
41+
# include <sys/time.h>
42+
# include <sys/resource.h>
43+
#endif
3744
#include <sys/types.h>
3845

3946
#ifdef HAVE_CONFIG_H
@@ -392,6 +399,13 @@ memlimit_sysinfo(size_t * memlimit)
392399
}
393400
#endif /* HAVE_SYSINFO */
394401

402+
#ifdef _WIN32
403+
static int
404+
memlimit_rlimit(size_t * memlimit)
405+
{
406+
return (0);
407+
}
408+
#else
395409
static int
396410
memlimit_rlimit(size_t * memlimit)
397411
{
@@ -441,6 +455,7 @@ memlimit_rlimit(size_t * memlimit)
441455
/* Success! */
442456
return (0);
443457
}
458+
#endif
444459

445460
#ifdef _SC_PHYS_PAGES
446461

@@ -555,4 +570,4 @@ memtouse(size_t maxmem, double maxmemfrac, size_t * memlimit)
555570
/* Return limit via the provided pointer. */
556571
*memlimit = memavail;
557572
return (0);
558-
}
573+
}

‎crypto/sha256.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
#include "php.h"
2828

2929
#include <sys/types.h>
30-
#include <stdint.h>
30+
#ifdef PHP_WIN32
31+
# include "win32/php_stdint.h"
32+
#else
33+
# include <stdint.h>
34+
#endif
3135
#include <string.h>
3236

3337
#include "sysendian.h"

‎crypto/sha256.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131

3232
#include <sys/types.h>
3333

34-
#include <stdint.h>
34+
#ifdef PHP_WIN32
35+
# include "win32/php_stdint.h"
36+
#else
37+
# include <stdint.h>
38+
#endif
3539

3640
typedef struct SHA256Context {
3741
uint32_t state[8];

‎crypto/sysendian.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040

4141
#else
4242

43-
#include <stdint.h>
43+
#ifdef PHP_WIN32
44+
# include "win32/php_stdint.h"
45+
#else
46+
# include <stdint.h>
47+
#endif
4448

4549
static inline uint32_t
4650
be32dec(const void *pp)

‎php_scrypt.c

-6
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,16 @@ ZEND_BEGIN_ARG_INFO_EX(scrypt_arginfo, 0, 0, 6)
5050
ZEND_ARG_INFO(0, keyLength)
5151
ZEND_END_ARG_INFO()
5252

53-
#ifndef PHP_WIN32
5453
ZEND_BEGIN_ARG_INFO_EX(scrypt_pickparams_arginfo, 0, 0, 3)
5554
ZEND_ARG_INFO(0, maxMemory)
5655
ZEND_ARG_INFO(0, memFraction)
5756
ZEND_ARG_INFO(0, maxTime)
5857
ZEND_END_ARG_INFO()
59-
#endif
6058
/* }}} */
6159

6260
static zend_function_entry scrypt_functions[] = {
6361
PHP_FE(scrypt, scrypt_arginfo)
64-
#ifndef PHP_WIN32
6562
PHP_FE(scrypt_pickparams, scrypt_pickparams_arginfo)
66-
#endif
6763
{NULL, NULL, NULL}
6864
};
6965

@@ -205,7 +201,6 @@ PHP_FUNCTION(scrypt)
205201
}
206202
/* }}} */
207203

208-
#ifndef PHP_WIN32
209204
/* {{{ proto array scrypt_pickparams(long maxMemory, double memFraction, double maxTime)
210205
* Returns N, r and p picked automatically for use with the scrypt function.
211206
*
@@ -258,4 +253,3 @@ PHP_FUNCTION(scrypt_pickparams)
258253
return;
259254
}
260255
/* }}} */
261-
#endif

‎php_scrypt.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@
3030
#define PHP_SCRYPT_EXTNAME "scrypt"
3131

3232
PHP_FUNCTION(scrypt);
33-
#ifndef PHP_WIN32
3433
PHP_FUNCTION(scrypt_pickparams);
35-
#endif
3634

3735
extern zend_module_entry scrypt_module_entry;
3836
#define phpext_scrypt_ptr &scrypt_module_entry
3937

40-
#endif
38+
#endif

‎php_scrypt_utils.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
#include "zend_config.w32.h"
3636
#endif
3737
#include "php.h"
38-
#include <stdint.h>
38+
#ifdef PHP_WIN32
39+
# include "win32/php_stdint.h"
40+
#else
41+
# include <stdint.h>
42+
#endif
3943

4044
/*
4145
* Casts a long into a uint64_t.
@@ -57,4 +61,4 @@ clampAndCast64(const char *variableName, long value, int *error);
5761
uint32_t
5862
clampAndCast32(const char *variableName, long value, int *error);
5963

60-
#endif
64+
#endif

0 commit comments

Comments
 (0)