summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Mai <l.mai@web.de>2016-02-29 08:45:12 +0100
committerTony Cook <tony@develop-help.com>2016-03-07 10:59:08 +1100
commit99fff99d79aa793bf9a6e0ce2bb18ced085ad1e2 (patch)
tree516c7b9ba0660b2089d4b7b7604e4211cd2ec251
parent01e331e519b4ccb213cadc7bfe7c04b8249e3289 (diff)
downloadperl-99fff99d79aa793bf9a6e0ce2bb18ced085ad1e2.tar.gz
util.c: make my_mem*/my_b* prototypes more like the originals
-rw-r--r--embed.fnc8
-rw-r--r--proto.h16
-rw-r--r--util.c44
3 files changed, 31 insertions, 37 deletions
diff --git a/embed.fnc b/embed.fnc
index 636b61ab08..a5fa27919c 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -932,10 +932,10 @@ p |int |mode_from_discipline|NULLOK const char* s|STRLEN len
Ap |const char* |moreswitches |NN const char* s
Ap |NV |my_atof |NN const char *s
#if (!defined(HAS_MEMCPY) && !defined(HAS_BCOPY)) || (!defined(HAS_MEMMOVE) && !defined(HAS_SAFE_MEMCPY) && !defined(HAS_SAFE_BCOPY))
-Anp |char* |my_bcopy |NN const char* from|NN char* to|I32 len
+Anp |void* |my_bcopy |NN const void* vfrom|NN void* vto|size_t len
#endif
#if !defined(HAS_BZERO) && !defined(HAS_MEMSET)
-Anp |char* |my_bzero |NN char* loc|I32 len
+Anp |void* |my_bzero |NN void* vloc|size_t len
#endif
Apr |void |my_exit |U32 status
Apr |void |my_failure_exit
@@ -946,10 +946,10 @@ Anp |void |atfork_unlock
Apmb |I32 |my_lstat
pX |I32 |my_lstat_flags |NULLOK const U32 flags
#if !defined(HAS_MEMCMP) || !defined(HAS_SANE_MEMCMP)
-AnpP |I32 |my_memcmp |NN const char* s1|NN const char* s2|I32 len
+AnpP |int |my_memcmp |NN const void* vs1|NN const void* vs2|size_t len
#endif
#if !defined(HAS_MEMSET)
-Anp |void* |my_memset |NN char* loc|I32 ch|I32 len
+Anp |void* |my_memset |NN void* vloc|int ch|size_t len
#endif
#if !defined(PERL_IMPLICIT_SYS)
Ap |I32 |my_pclose |NULLOK PerlIO* ptr
diff --git a/proto.h b/proto.h
index cfd01d8286..98ffb3d2e7 100644
--- a/proto.h
+++ b/proto.h
@@ -3583,9 +3583,9 @@ PERL_CALLCONV_NO_RET int Perl_magic_regdatum_set(pTHX_ SV* sv, MAGIC* mg)
#endif
#if !defined(HAS_BZERO) && !defined(HAS_MEMSET)
-PERL_CALLCONV char* Perl_my_bzero(char* loc, I32 len);
+PERL_CALLCONV void* Perl_my_bzero(void* vloc, size_t len);
#define PERL_ARGS_ASSERT_MY_BZERO \
- assert(loc)
+ assert(vloc)
#endif
#if !defined(HAS_GETENV_LEN)
PERL_CALLCONV char* Perl_getenv_len(pTHX_ const char *env_elem, unsigned long *len);
@@ -3593,16 +3593,16 @@ PERL_CALLCONV char* Perl_getenv_len(pTHX_ const char *env_elem, unsigned long *l
assert(env_elem); assert(len)
#endif
#if !defined(HAS_MEMCMP) || !defined(HAS_SANE_MEMCMP)
-PERL_CALLCONV I32 Perl_my_memcmp(const char* s1, const char* s2, I32 len)
+PERL_CALLCONV int Perl_my_memcmp(const void* vs1, const void* vs2, size_t len)
__attribute__pure__;
#define PERL_ARGS_ASSERT_MY_MEMCMP \
- assert(s1); assert(s2)
+ assert(vs1); assert(vs2)
#endif
#if !defined(HAS_MEMSET)
-PERL_CALLCONV void* Perl_my_memset(char* loc, I32 ch, I32 len);
+PERL_CALLCONV void* Perl_my_memset(void* vloc, int ch, size_t len);
#define PERL_ARGS_ASSERT_MY_MEMSET \
- assert(loc)
+ assert(vloc)
#endif
#if !defined(HAS_MKDIR) || !defined(HAS_RMDIR)
# if defined(PERL_IN_PP_SYS_C)
@@ -3801,9 +3801,9 @@ PERL_CALLCONV bool Perl_do_exec3(pTHX_ const char *incmd, int fd, int do_report)
assert(incmd)
#endif
#if (!defined(HAS_MEMCPY) && !defined(HAS_BCOPY)) || (!defined(HAS_MEMMOVE) && !defined(HAS_SAFE_MEMCPY) && !defined(HAS_SAFE_BCOPY))
-PERL_CALLCONV char* Perl_my_bcopy(const char* from, char* to, I32 len);
+PERL_CALLCONV void* Perl_my_bcopy(const void* vfrom, void* vto, size_t len);
#define PERL_ARGS_ASSERT_MY_BCOPY \
- assert(from); assert(to)
+ assert(vfrom); assert(vto)
#endif
#if defined(DEBUGGING)
PERL_CALLCONV int Perl_get_debug_opts(pTHX_ const char **s, bool givehelp)
diff --git a/util.c b/util.c
index e87246bfd2..4c9516b872 100644
--- a/util.c
+++ b/util.c
@@ -2263,17 +2263,17 @@ Perl_unlnk(pTHX_ const char *f) /* unlink all versions of a file */
}
#endif
-/* this is a drop-in replacement for bcopy() */
+/* this is a drop-in replacement for bcopy(), except for the return
+ * value, which we need to be able to emulate memcpy() */
#if (!defined(HAS_MEMCPY) && !defined(HAS_BCOPY)) || (!defined(HAS_MEMMOVE) && !defined(HAS_SAFE_MEMCPY) && !defined(HAS_SAFE_BCOPY))
-char *
-Perl_my_bcopy(const char *from, char *to, I32 len)
+void *
+Perl_my_bcopy(const void *vfrom, void *vto, size_t len)
{
- char * const retval = to;
+ const unsigned char *from = (const unsigned char *)vfrom;
+ unsigned char *to = (unsigned char *)vto;
PERL_ARGS_ASSERT_MY_BCOPY;
- assert(len >= 0);
-
if (from - to >= 0) {
while (len--)
*to++ = *from++;
@@ -2284,57 +2284,51 @@ Perl_my_bcopy(const char *from, char *to, I32 len)
while (len--)
*(--to) = *(--from);
}
- return retval;
+ return vto;
}
#endif
/* this is a drop-in replacement for memset() */
#ifndef HAS_MEMSET
void *
-Perl_my_memset(char *loc, I32 ch, I32 len)
+Perl_my_memset(void *vloc, int ch, size_t len)
{
- char * const retval = loc;
+ unsigned char *loc = (unsigned char *)vloc;
PERL_ARGS_ASSERT_MY_MEMSET;
- assert(len >= 0);
-
while (len--)
*loc++ = ch;
- return retval;
+ return vloc;
}
#endif
/* this is a drop-in replacement for bzero() */
#if !defined(HAS_BZERO) && !defined(HAS_MEMSET)
-char *
-Perl_my_bzero(char *loc, I32 len)
+void *
+Perl_my_bzero(void *vloc, size_t len)
{
- char * const retval = loc;
+ unsigned char *loc = (unsigned char *)vloc;
PERL_ARGS_ASSERT_MY_BZERO;
- assert(len >= 0);
-
while (len--)
*loc++ = 0;
- return retval;
+ return vloc;
}
#endif
/* this is a drop-in replacement for memcmp() */
#if !defined(HAS_MEMCMP) || !defined(HAS_SANE_MEMCMP)
-I32
-Perl_my_memcmp(const char *s1, const char *s2, I32 len)
+int
+Perl_my_memcmp(const void *vs1, const void *vs2, size_t len)
{
- const U8 *a = (const U8 *)s1;
- const U8 *b = (const U8 *)s2;
- I32 tmp;
+ const U8 *a = (const U8 *)vs1;
+ const U8 *b = (const U8 *)vs2;
+ int tmp;
PERL_ARGS_ASSERT_MY_MEMCMP;
- assert(len >= 0);
-
while (len--) {
if ((tmp = *a++ - *b++))
return tmp;