]> granicus.if.org Git - php/commitdiff
- Nuke unncessary checks already done elsewhere (ZEND)
authorJani Taskinen <jani@php.net>
Mon, 25 Aug 2008 13:42:46 +0000 (13:42 +0000)
committerJani Taskinen <jani@php.net>
Mon, 25 Aug 2008 13:42:46 +0000 (13:42 +0000)
- Use the correct type header files if available. (win32 does what it does)
- inline definition is in php_config.h, so include it always.

ext/standard/config.m4
ext/standard/crypt_freesec.c
ext/standard/crypt_freesec.h

index 79839bebc8deca68f5ea68e915738d14ad605084..125e7266a3ed0f71e1b93ae29fd7112ac8e99134 100644 (file)
@@ -463,25 +463,6 @@ if test "$ac_cv_type_mbstate_t" = "yes"; then
   AC_DEFINE([HAVE_MBSTATE_T], 1, [Define if your system has mbstate_t in wchar.h])
 fi
 
-dnl
-dnl Check for u_int32_t
-dnl
-AC_CACHE_CHECK([for u_int32_t], [ac_cv_type_u_int32_t],[
-AC_TRY_COMPILE([
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-],[
-int __tmp__() { u_int32_t a; }
-],[
-  ac_cv_type_u_int32_t=yes
-],[
-  ac_cv_type_u_int32_t=no
-])])
-if test "$ac_cv_type_u_int32_t" = "yes"; then
-  AC_DEFINE([HAVE_U_INT32_T], 1, [Define if your system has u_int32_t in sys/types.h])
-fi
-
 dnl
 dnl Setup extension sources
 dnl
index b408a85f314addddfe5acf9061a70b660d94064c..7ed277092dfcc9f3f42eb7d335be7635aa6ba458 100644 (file)
 #include <sys/types.h>
 #include <string.h>
 
-#ifdef TEST
-#include <stdio.h>
-#endif
-
-
-#if defined(__GNUC__)
-# ifdef inline
-# undef inline
-# endif
-# define inline inline __attribute__((always_inline))
-#elif defined(_MSC_VER)
-# define inline __forceinline
-#else
-# ifndef inline
-#  define inline
-# endif
-#endif
-
 #include "crypt_freesec.h"
 
 #define _PASSWORD_EFMT1 '_'
@@ -172,7 +154,7 @@ static u_char       pbox[32] = {
         2,  8, 24, 14, 32, 27,  3,  9, 19, 13, 30,  6, 22, 11,  4, 25
 };
 
-static u_int32_t bits32[32] =
+static uint32_t bits32[32] =
 {
        0x80000000, 0x40000000, 0x20000000, 0x10000000,
        0x08000000, 0x04000000, 0x02000000, 0x01000000,
@@ -192,11 +174,11 @@ static unsigned char      ascii64[] =
 /*       0123456789012345678901234567890123456789012345678901234567890123 */
 
 static u_char m_sbox[4][4096];
-static u_int32_t psbox[4][256];
-static u_int32_t ip_maskl[8][256], ip_maskr[8][256];
-static u_int32_t fp_maskl[8][256], fp_maskr[8][256];
-static u_int32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
-static u_int32_t comp_maskl[8][128], comp_maskr[8][128];
+static uint32_t psbox[4][256];
+static uint32_t ip_maskl[8][256], ip_maskr[8][256];
+static uint32_t fp_maskl[8][256], fp_maskr[8][256];
+static uint32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
+static uint32_t comp_maskl[8][128], comp_maskr[8][128];
 
 static inline int
 ascii_to_bin(char ch)
@@ -220,8 +202,8 @@ void
 _crypt_extended_init(void)
 {
        int i, j, b, k, inbit, obit;
-       u_int32_t *p, *il, *ir, *fl, *fr;
-       u_int32_t *bits28, *bits24;
+       uint32_t *p, *il, *ir, *fl, *fr;
+       uint32_t *bits28, *bits24;
        u_char inv_key_perm[64];
        u_char u_key_perm[56];
        u_char inv_comp_perm[56];
@@ -359,9 +341,9 @@ des_init_local(struct php_crypt_extended_data *data)
 }
 
 static void
-setup_salt(u_int32_t salt, struct php_crypt_extended_data *data)
+setup_salt(uint32_t salt, struct php_crypt_extended_data *data)
 {
-       u_int32_t       obit, saltbit, saltbits;
+       uint32_t        obit, saltbit, saltbits;
        int     i;
 
        if (salt == data->old_salt)
@@ -383,19 +365,19 @@ setup_salt(u_int32_t salt, struct php_crypt_extended_data *data)
 static int
 des_setkey(const char *key, struct php_crypt_extended_data *data)
 {
-       u_int32_t       k0, k1, rawkey0, rawkey1;
+       uint32_t        k0, k1, rawkey0, rawkey1;
        int     shifts, round;
 
        rawkey0 =
-               (u_int32_t)(u_char)key[3] |
-               ((u_int32_t)(u_char)key[2] << 8) |
-               ((u_int32_t)(u_char)key[1] << 16) |
-               ((u_int32_t)(u_char)key[0] << 24);
+               (uint32_t)(u_char)key[3] |
+               ((uint32_t)(u_char)key[2] << 8) |
+               ((uint32_t)(u_char)key[1] << 16) |
+               ((uint32_t)(u_char)key[0] << 24);
        rawkey1 =
-               (u_int32_t)(u_char)key[7] |
-               ((u_int32_t)(u_char)key[6] << 8) |
-               ((u_int32_t)(u_char)key[5] << 16) |
-               ((u_int32_t)(u_char)key[4] << 24);
+               (uint32_t)(u_char)key[7] |
+               ((uint32_t)(u_char)key[6] << 8) |
+               ((uint32_t)(u_char)key[5] << 16) |
+               ((uint32_t)(u_char)key[4] << 24);
 
        if ((rawkey0 | rawkey1)
            && rawkey0 == data->old_rawkey0
@@ -435,7 +417,7 @@ des_setkey(const char *key, struct php_crypt_extended_data *data)
         */
        shifts = 0;
        for (round = 0; round < 16; round++) {
-               u_int32_t       t0, t1;
+               uint32_t        t0, t1;
 
                shifts += key_shifts[round];
 
@@ -466,14 +448,14 @@ des_setkey(const char *key, struct php_crypt_extended_data *data)
 }
 
 static int
-do_des(u_int32_t l_in, u_int32_t r_in, u_int32_t *l_out, u_int32_t *r_out,
+do_des(uint32_t l_in, uint32_t r_in, uint32_t *l_out, uint32_t *r_out,
        int count, struct php_crypt_extended_data *data)
 {
        /*
         *      l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format.
         */
-       u_int32_t       l, r, *kl, *kr, *kl1, *kr1;
-       u_int32_t       f, r48l, r48r, saltbits;
+       uint32_t        l, r, *kl, *kr, *kl1, *kr1;
+       uint32_t        f, r48l, r48r, saltbits;
        int     round;
 
        if (count == 0) {
@@ -584,24 +566,24 @@ do_des(u_int32_t l_in, u_int32_t r_in, u_int32_t *l_out, u_int32_t *r_out,
 }
 
 static int
-des_cipher(const char *in, char *out, u_int32_t salt, int count,
+des_cipher(const char *in, char *out, uint32_t salt, int count,
        struct php_crypt_extended_data *data)
 {
-       u_int32_t       l_out, r_out, rawl, rawr;
+       uint32_t        l_out, r_out, rawl, rawr;
        int     retval;
 
        setup_salt(salt, data);
 
        rawl =
-               (u_int32_t)(u_char)in[3] |
-               ((u_int32_t)(u_char)in[2] << 8) |
-               ((u_int32_t)(u_char)in[1] << 16) |
-               ((u_int32_t)(u_char)in[0] << 24);
+               (uint32_t)(u_char)in[3] |
+               ((uint32_t)(u_char)in[2] << 8) |
+               ((uint32_t)(u_char)in[1] << 16) |
+               ((uint32_t)(u_char)in[0] << 24);
        rawr =
-               (u_int32_t)(u_char)in[7] |
-               ((u_int32_t)(u_char)in[6] << 8) |
-               ((u_int32_t)(u_char)in[5] << 16) |
-               ((u_int32_t)(u_char)in[4] << 24);
+               (uint32_t)(u_char)in[7] |
+               ((uint32_t)(u_char)in[6] << 8) |
+               ((uint32_t)(u_char)in[5] << 16) |
+               ((uint32_t)(u_char)in[4] << 24);
 
        retval = do_des(rawl, rawr, &l_out, &r_out, count, data);
 
@@ -622,7 +604,7 @@ _crypt_extended_r(const char *key, const char *setting,
        struct php_crypt_extended_data *data)
 {
        int             i;
-       u_int32_t       count, salt, l, r0, r1, keybuf[2];
+       uint32_t        count, salt, l, r0, r1, keybuf[2];
        u_char          *p, *q;
 
        if (!data->initialized)
index f7f499470ae6063aa8c7967d17a27f388f39ad5a..f4a63d1630bff5987e5fa6925f4a59b345f2bf39 100644 (file)
@@ -1,17 +1,24 @@
 /* $Id$ */
+
 #ifndef _CRYPT_FREESEC_H
 #define _CRYPT_FREESEC_H
 
+#include "php_config.h"
 
 #if PHP_WIN32
 # include "win32/php_stdint.h"
 #else
-# include "php_config.h"
-# if HAVE_STDINT_H
+# if HAVE_INTTYPES_H
+#  include <inttypes.h>
+# elif HAVE_STDINT_H
 #  include <stdint.h>
 # endif
-# ifndef HAVE_U_INT32_T
-   typedef uint32_t u_int32_t;
+# ifndef HAVE_UINT32_T
+#  if SIZEOF_INT == 4
+typedef unsigned int uint32_t;
+#  elif SIZEOF_LONG == 4
+typedef unsigned long int uint32_t;
+#  endif
 # endif
 #endif
 
 
 struct php_crypt_extended_data {
        int initialized;
-       u_int32_t saltbits;
-       u_int32_t old_salt;
-       u_int32_t en_keysl[16], en_keysr[16];
-       u_int32_t de_keysl[16], de_keysr[16];
-       u_int32_t old_rawkey0, old_rawkey1;
+       uint32_t saltbits;
+       uint32_t old_salt;
+       uint32_t en_keysl[16], en_keysr[16];
+       uint32_t de_keysl[16], de_keysr[16];
+       uint32_t old_rawkey0, old_rawkey1;
        char output[21];
 };