diff --git a/src/acconfig.h b/src/acconfig.h index e8c5f9d6bbc9505f31d80eaed806b145922eb09c..bca587a107d866a9ceab57b73c2973145ad3c65f 100644 --- a/src/acconfig.h +++ b/src/acconfig.h @@ -295,9 +295,6 @@ /* ... by using the RDTSC instruction? */ #undef OWN_GETHRTIME_RDTSC -/* Define if you have a working, 8-bit-clean memcmp */ -#undef HAVE_MEMCMP - /* Define if it is possible to allocate PROT_EXEC memory with mmap */ #undef MEXEC_USES_MMAP diff --git a/src/builtin_functions.c b/src/builtin_functions.c index e4e66448358b504b25389d356c05d5bd49953fe3..91230a136df5e2b1e0b6d119509c1a963d939154 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -1205,7 +1205,7 @@ PMOD_EXPORT void f_has_prefix(INT32 args) } if (a->size_shift == b->size_shift) { - int res = !MEMCMP(a->str, b->str, b->len << b->size_shift); + int res = !memcmp(a->str, b->str, b->len << b->size_shift); pop_n_elems(args); push_int(res); return; @@ -1278,7 +1278,7 @@ PMOD_EXPORT void f_has_suffix(INT32 args) } if (a->size_shift == b->size_shift) { - int res = !MEMCMP(a->str + ((a->len - b->len)<<b->size_shift), b->str, + int res = !memcmp(a->str + ((a->len - b->len)<<b->size_shift), b->str, b->len << b->size_shift); pop_n_elems(args); push_int(res); diff --git a/src/configure.in b/src/configure.in index b046506b9406627acc016226bc55e145a4c064bc..808440090b2eee0caa49df5404c4066203772d2d 100644 --- a/src/configure.in +++ b/src/configure.in @@ -4399,27 +4399,6 @@ PIKE_CHECK_CONSTANTS(recursive mutex flag, ######################################################################## -# NOTE: The following test is hardcoded to fail when crosscompiling -# It also clobbers $LIBOBJS. - -ifdef([m4_pattern_allow], [ - # Handle the latest autoconf incompatibility... - m4_pattern_allow(LIBOBJS) -]) -OLD_LIBOBJS="${LIBOBJS}" - -AC_FUNC_MEMCMP - -# Old Autoconf set memcmp_clean while newer define memcmp_working -if test "x$ac_cv_func_memcmp_clean" = "xyes" -o \ - "x$ac_cv_func_memcmp_working" = "xyes"; then - AC_DEFINE(HAVE_MEMCMP) -fi - -LIBOBJS="${OLD_LIBOBJS}" - -######################################################################## - AC_FUNC_MMAP if test "x$ac_cv_func_mmap_fixed_mapped" = "xyes"; then diff --git a/src/lexer.h b/src/lexer.h index 29bb107dfc2393ab67faedcf53754694e0b000c9..d0ff62291ebba1bbc148a601e06a229b96b7377e 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -43,7 +43,7 @@ } while(0) #define TWO_CHAR(X,Y) ((X)<<8)+(Y) -#define ISWORD(X) ((len == strlen(X)) && !MEMCMP(buf,X,strlen(X))) +#define ISWORD(X) ((len == strlen(X)) && !memcmp(buf,X,strlen(X))) /* * Function renaming diff --git a/src/modules/Parser/xml.cmod b/src/modules/Parser/xml.cmod index 58d46e47f2a362bc107f6b2935b172db5d5d262a..b0065be5f150dd60bc75474512930888c75ba290 100644 --- a/src/modules/Parser/xml.cmod +++ b/src/modules/Parser/xml.cmod @@ -3387,7 +3387,7 @@ PIKEFUN string autoconvert(string s) while(isSpace(STR0(s)[pos])) pos++; /* "autoconvert: <?xml .version */ - if(MEMCMP(STR0(s)+pos,"version",7)) break; + if(memcmp(STR0(s)+pos,"version",7)) break; pos+=7; /* <?xml version. = "1.0" */ @@ -3420,7 +3420,7 @@ PIKEFUN string autoconvert(string s) while(isSpace(STR0(s)[pos])) pos++; /* <?xml version = "1.0" .encoding="encname" */ - if(MEMCMP("encoding",STR0(s)+pos,8)) break; + if(memcmp("encoding",STR0(s)+pos,8)) break; pos+=8; /* <?xml version = "1.0" encoding. ="encname" */ diff --git a/src/pike_memory.c b/src/pike_memory.c index 91617ad995879ecfafc0f82e277f776747efedc9..5e1dd549b422812aaaac5ba838645da60905c079 100644 --- a/src/pike_memory.c +++ b/src/pike_memory.c @@ -1585,12 +1585,12 @@ void check_pad(struct memhdr *mh, int freeok) /* fprintf(stderr,"Checking %p(%d) %ld\n",mem, size, q); */ #if 1 /* optimization? */ - if(MEMCMP(mem - DEBUG_MALLOC_PAD, mem+size, DEBUG_MALLOC_PAD)) + if(memcmp(mem - DEBUG_MALLOC_PAD, mem+size, DEBUG_MALLOC_PAD)) { q= (((long)mem) ^ 0x555555) + (size * 9248339); q%=RNDSIZE; - if(MEMCMP(mem - DEBUG_MALLOC_PAD, rndbuf+q, DEBUG_MALLOC_PAD)) + if(memcmp(mem - DEBUG_MALLOC_PAD, rndbuf+q, DEBUG_MALLOC_PAD)) { out_biking=1; fprintf(stderr,"Pre-padding overwritten for " @@ -1599,7 +1599,7 @@ void check_pad(struct memhdr *mh, int freeok) abort(); } - if(MEMCMP(mem + size, rndbuf+q, DEBUG_MALLOC_PAD)) + if(memcmp(mem + size, rndbuf+q, DEBUG_MALLOC_PAD)) { out_biking=1; fprintf(stderr,"Post-padding overwritten for " @@ -2945,7 +2945,7 @@ static LOCATION low_dynamic_location(char type, const char *file, unsigned int str_bin_len = EXTRACT_UWORD (str_bin_base); str_bin_base += 2; if (str_bin_len != bin_data_len || - MEMCMP (bin_data, str_bin_base, str_bin_len)) + memcmp (bin_data, str_bin_base, str_bin_len)) continue; } diff --git a/src/pike_search_engine2.c b/src/pike_search_engine2.c index 60bbd3398d8676f52c28955b09c11f7ffa17462c..dd4b418eb4b53eaedf129f93371d4d625739c9d5 100644 --- a/src/pike_search_engine2.c +++ b/src/pike_search_engine2.c @@ -21,7 +21,7 @@ static INLINE HCHAR *NameNH(MEMCHR)(HCHAR *p, NCHAR c, ptrdiff_t e) static INLINE int NameNH(MEMCMP)(NCHAR *a, HCHAR *b, ptrdiff_t e) { #if NSHIFT == HSHIFT - return MEMCMP(a, b, sizeof(HCHAR)*e); + return memcmp(a, b, sizeof(HCHAR)*e); #else for(;e;e--,b++,a++) { diff --git a/src/pike_threadlib.h b/src/pike_threadlib.h index 710dce2a5817aee3dc680e91b5b57695f169f0e2..c01891a97b7c8c28a568e2af2899cdf81020c750 100644 --- a/src/pike_threadlib.h +++ b/src/pike_threadlib.h @@ -408,7 +408,7 @@ PMOD_EXPORT int co_destroy(COND_T *c); #endif #ifndef th_equal -#define th_equal(X,Y) (!MEMCMP(&(X),&(Y),sizeof(THREAD_T))) +#define th_equal(X,Y) (!memcmp(&(X),&(Y),sizeof(THREAD_T))) #endif #ifndef th_hash diff --git a/src/port.c b/src/port.c index c55cde789d55dc253f70dc1e6dcebcc2acb3e022..a0274529d8883d2820b564824e268cd82d05e3ea 100644 --- a/src/port.c +++ b/src/port.c @@ -262,23 +262,6 @@ PMOD_EXPORT int STRCASECMP(const char *a,const char *b) } #endif -#ifndef HAVE_MEMCMP -PMOD_EXPORT int MEMCMP(const void *bb,const void *aa,size_t s) -{ - unsigned char *a=(unsigned char *)aa; - unsigned char *b=(unsigned char *)bb; - for(;s;s--,b++,a++) - { - if(*b!=*a) - { - if(*b<*a) return -1; - return 1; - } - } - return 0; -} -#endif - #ifndef HAVE_MEMCHR PMOD_EXPORT void *MEMCHR(const void *p,char c,size_t e) { diff --git a/src/port.h b/src/port.h index de6a0bbc5857e295c3d780aec4bcf63d3b8de18c..82540248ee1aeda914b15ec02b140ed5f0a59212 100644 --- a/src/port.h +++ b/src/port.h @@ -179,11 +179,8 @@ PMOD_EXPORT int STRCASECMP(const char *a,const char *b); #define HAVE_MEMMOVE 1 #define MEMMOVE memmove -#ifndef HAVE_MEMCMP -PMOD_EXPORT int MEMCMP(const void *b,const void *a,size_t s); -#else -# define MEMCMP(X,Y,Z) memcmp((char*)(X),(char*)(Y),(Z)) -#endif +#define HAVE_MEMCMP 1 +#define MEMCMP(X,Y,Z) memcmp((char*)(X),(char*)(Y),(Z)) #ifndef HAVE_MEMCHR PMOD_EXPORT void *MEMCHR(const void *p,char c,size_t e); diff --git a/src/post_modules/GSSAPI/gssapi.cmod b/src/post_modules/GSSAPI/gssapi.cmod index bca643451018e7e0daff842b328988a3260fcc22..b7bb435f0f083431ae04f5aa304d0fa8b5144a58 100644 --- a/src/post_modules/GSSAPI/gssapi.cmod +++ b/src/post_modules/GSSAPI/gssapi.cmod @@ -260,7 +260,7 @@ static void cleanup_oid_set (gss_OID_set *oid_set) #define IS_SAME_OID(A, B) \ (A == B || (A->length == B->length && \ - !MEMCMP (A->elements, B->elements, A->length))) + !memcmp (A->elements, B->elements, A->length))) #define COPY_OID(DST, SRC) do { \ gss_OID dst_ = (DST), src_ = (SRC); \ diff --git a/src/stralloc.c b/src/stralloc.c index 2c130ea3b7c54e156d0bfe9e294bab3f023441e3..8c87c5a08ea15a2744a34e4bf2ae0a2e64d65076 100644 --- a/src/stralloc.c +++ b/src/stralloc.c @@ -470,7 +470,7 @@ static struct pike_string *internal_findstring(const char *s, size_shift == curr->size_shift && hval == curr->hval && ( curr->str == s || - !MEMCMP(curr->str, s,len<<size_shift))) /* found it */ + !memcmp(curr->str, s,len<<size_shift))) /* found it */ { /* *prev = curr->next; */ /* curr->next = *base; */ @@ -1496,15 +1496,15 @@ int low_quick_binary_strcmp(const char *a, ptrdiff_t alen, int tmp; if(alen > blen) { - tmp=MEMCMP(a, b, blen); + tmp=memcmp(a, b, blen); if(tmp) return tmp; return 1; }else if(alen < blen){ - tmp=MEMCMP(a, b, alen); + tmp=memcmp(a, b, alen); if(tmp) return tmp; return -1; }else{ - return MEMCMP(a, b, alen); + return memcmp(a, b, alen); } } @@ -1520,15 +1520,15 @@ ptrdiff_t generic_quick_binary_strcmp(const char *a, int tmp; if(alen > blen) { - tmp=MEMCMP(a, b, blen); + tmp=memcmp(a, b, blen); if(tmp) return tmp; return 1; }else if(alen < blen){ - tmp=MEMCMP(a, b, alen); + tmp=memcmp(a, b, alen); if(tmp) return tmp; return -1; }else{ - return MEMCMP(a, b, alen); + return memcmp(a, b, alen); } }else{ ptrdiff_t pos; @@ -1592,7 +1592,7 @@ ptrdiff_t generic_find_binary_prefix(const char *a, PMOD_EXPORT int c_compare_string(struct pike_string *s, char *foo, int len) { - return s->len == len && s->size_shift == 0 && !MEMCMP(s->str,foo,len); + return s->len == len && s->size_shift == 0 && !memcmp(s->str,foo,len); } #ifndef HAVE_STRCOLL diff --git a/src/stralloc.h b/src/stralloc.h index fbb8ab72b9db5bb211255135b7a15f21123f20c3..d3c687fa252b300cb2e59504d5937f73b730a128 100644 --- a/src/stralloc.h +++ b/src/stralloc.h @@ -263,9 +263,9 @@ PMOD_EXPORT extern struct shared_string_location *all_shared_string_locations; #define convert_1_to_1(X,Y,Z) memcpy((X),(Y),(Z)<<1) #define convert_2_to_2(X,Y,Z) memcpy((X),(Y),(Z)<<2) -#define compare_0_to_0(X,Y,Z) MEMCMP((char *)(X),(char *)(Y),(Z)) -#define compare_1_to_1(X,Y,Z) MEMCMP((char *)(X),(char *)(Y),(Z)<<1) -#define compare_2_to_2(X,Y,Z) MEMCMP((char *)(X),(char *)(Y),(Z)<<2) +#define compare_0_to_0(X,Y,Z) memcmp((char *)(X),(char *)(Y),(Z)) +#define compare_1_to_1(X,Y,Z) memcmp((char *)(X),(char *)(Y),(Z)<<1) +#define compare_2_to_2(X,Y,Z) memcmp((char *)(X),(char *)(Y),(Z)<<2) #define CONVERT(FROM,TO) \ void PIKE_CONCAT4(convert_,FROM,_to_,TO)(PIKE_CONCAT(p_wchar,TO) *to, const PIKE_CONCAT(p_wchar,FROM) *from, ptrdiff_t len); \