Last active
September 29, 2020 14:00
-
-
Save dougpuob/433f16ae9286d562dce30774a3b84903 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [Repo] https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncpy.c | |
// [Local] C:\petzone\reference\gcc\gcc.git\gcc\testsuite\gcc.c-torture\execute\builtins\lib\strncpy.c | |
extern void abort(void); | |
extern int inside_main; | |
typedef __SIZE_TYPE__ size_t; | |
__attribute__ ((__noinline__)) | |
char * | |
strncpy(char *s1, const char *s2, size_t n) | |
{ | |
char *dest = s1; | |
#ifdef __OPTIMIZE__ | |
if (inside_main) | |
abort(); | |
#endif | |
for (; *s2 && n; n--) | |
*s1++ = *s2++; | |
while (n--) | |
*s1++ = 0; | |
return dest; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment