Modernize.

This commit is contained in:
Dag-Erling Smørgrav 2018-05-06 03:45:56 +02:00
parent d6e82b474f
commit 56bd595396
6 changed files with 22 additions and 12 deletions

View file

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2015 The University of Oslo * Copyright (c) 2015-2018 The University of Oslo
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -30,6 +30,12 @@
#ifndef CRYB_MEMCPY_S_H_INCLUDED #ifndef CRYB_MEMCPY_S_H_INCLUDED
#define CRYB_MEMCPY_S_H_INCLUDED #define CRYB_MEMCPY_S_H_INCLUDED
#ifndef CRYB_TO
#include <cryb/to.h>
#endif
CRYB_BEGIN
int cryb_memcpy_s(void *, size_t, const void *, size_t); int cryb_memcpy_s(void *, size_t, const void *, size_t);
#if !HAVE_MEMCPY_S #if !HAVE_MEMCPY_S
@ -37,4 +43,6 @@ int cryb_memcpy_s(void *, size_t, const void *, size_t);
#define memcpy_s(arg, ...) cryb_memcpy_s(arg, __VA_ARGS__) #define memcpy_s(arg, ...) cryb_memcpy_s(arg, __VA_ARGS__)
#endif #endif
CRYB_END
#endif #endif

View file

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2015 The University of Oslo * Copyright (c) 2015-2018 The University of Oslo
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2015 Dag-Erling Smørgrav * Copyright (c) 2015-2018 The University of Oslo
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -72,6 +72,6 @@ CRYB_RESTORE_COVERAGE
return (EINVAL); return (EINVAL);
} }
for (i = 0; i < dsz && i < n; ++i) for (i = 0; i < dsz && i < n; ++i)
((volatile unsigned char *)d)[i] = ((unsigned char *)s)[i]; ((volatile uint8_t *)d)[i] = ((const uint8_t *)s)[i];
return (0); return (0);
} }

View file

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2015 The University of Oslo * Copyright (c) 2015-2018 The University of Oslo
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -55,7 +55,7 @@ CRYB_DISABLE_COVERAGE
return (ERANGE); return (ERANGE);
CRYB_RESTORE_COVERAGE CRYB_RESTORE_COVERAGE
for (i = 0; i < n && i < dsz; ++i) for (i = 0; i < n && i < dsz; ++i)
((volatile unsigned char *)d)[i] = (unsigned char)ch; ((volatile uint8_t *)d)[i] = (uint8_t)ch;
if (n > dsz) if (n > dsz)
return (EOVERFLOW); return (EOVERFLOW);
return (0); return (0);

View file

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2015 Dag-Erling Smørgrav * Copyright (c) 2015-2018 The University of Oslo
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -289,16 +289,18 @@ t_prepare(int argc, char *argv[])
t_add_test(t_memcpy_s_null_d, NULL, "null destination"); t_add_test(t_memcpy_s_null_d, NULL, "null destination");
n = sizeof t_plain_cases / sizeof t_plain_cases[0]; n = sizeof t_plain_cases / sizeof t_plain_cases[0];
for (i = 0; i < n; ++i) for (i = 0; i < n; ++i)
t_add_test(t_memcpy_s, &t_plain_cases[i], t_add_test(t_memcpy_s, &t_plain_cases[i], "%s",
t_plain_cases[i].desc); t_plain_cases[i].desc);
n = sizeof t_overlap_cases / sizeof t_overlap_cases[0]; n = sizeof t_overlap_cases / sizeof t_overlap_cases[0];
for (i = 0; i < n; ++i) for (i = 0; i < n; ++i)
t_add_test(t_memcpy_s_overlap, &t_overlap_cases[i], t_add_test(t_memcpy_s_overlap, &t_overlap_cases[i], "%s",
t_overlap_cases[i].desc); t_overlap_cases[i].desc);
return (0); return (0);
} }
void int
t_cleanup(void) main(int argc, char *argv[])
{ {
t_main(t_prepare, NULL, argc, argv);
} }

View file

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2015 The University of Oslo * Copyright (c) 2015-2018 The University of Oslo
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without