PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
_wmemset.c
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
11#define SYSCLIB_DISABLE_BUILTINS
12#include <sysclib.h>
13
14// non-standard function (not to be confused with the wchar_t related function)
15void *_wmemset(u32 *dest, u32 c, size_t size)
16{
17 void *result;
18 s32 v4;
19 s32 v5;
20
21 result = dest;
22 v4 = (u32)size >> 2;
23 if (v4 > 0)
24 {
25 v5 = 0;
26 if ((v4 & 3) == 0)
27 {
28 goto LABEL_8;
29 }
30 do
31 {
32 *dest++ = c;
33 v5 += 1;
34 }
35 while ((v4 & 3) != v5);
36 if (v5 != v4)
37 {
38LABEL_8:
39 do
40 {
41 *dest = c;
42 dest[1] = c;
43 dest[2] = c;
44 dest[3] = c;
45 v5 += 4;
46 dest += 4;
47 }
48 while (v5 != v4);
49 }
50 }
51 return result;
52}